Click here to Skip to main content
15,887,027 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: DP not Working Pin
Meshack Musundi2-Aug-16 22:33
professionalMeshack Musundi2-Aug-16 22:33 
QuestionScrolling data table area on a XAML page Pin
Stephen Holdorf26-Jul-16 13:41
Stephen Holdorf26-Jul-16 13:41 
AnswerRe: Scrolling data table area on a XAML page Pin
Mycroft Holmes26-Jul-16 14:32
professionalMycroft Holmes26-Jul-16 14:32 
GeneralRe: Scrolling data table area on a XAML page Pin
Stephen Holdorf27-Jul-16 0:31
Stephen Holdorf27-Jul-16 0:31 
GeneralRe: Scrolling data table area on a XAML page Pin
Mycroft Holmes27-Jul-16 12:44
professionalMycroft Holmes27-Jul-16 12:44 
QuestionWhere to call OnPropertyChanged Pin
Bernhard Hiller25-Jul-16 21:47
Bernhard Hiller25-Jul-16 21:47 
AnswerRe: Where to call OnPropertyChanged Pin
Gerry Schmitz26-Jul-16 3:47
mveGerry Schmitz26-Jul-16 3:47 
QuestionEnter key invokes button click Pin
GrooverFromHolland23-Jul-16 9:44
GrooverFromHolland23-Jul-16 9:44 
Hi all,
This is my very first WPf-project, so please have some consideration and don’t advise me on MVVM .
Everything I in my project is working fine except one thing:
Whenever I hit the enter key on my keyboard a button gets the click event.
This button is not default button and the only event registered with this button is the click-event.
This is driving me insane.Confused | :confused:
If I put a breakpoint in the click event handler the routedEventsArgs e is button base click.
Here is the code related to this problem:

XML
<Style x:Key="ButtonStyle" TargetType="Button">
            <Setter Property="OverridesDefaultStyle" Value="True" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <Setter Property="Foreground" Value="White" />
            <Setter Property="IsEnabled" Value="True" />
            <Setter Property="Width" Value="Auto" />
            <Setter Property="Height" Value="Auto" />
            <Setter Property="Margin" Value="14,5,0,5" />            
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                        <GradientStop Offset="0" Color="Black" />
                        <GradientStop Offset="1" Color="#FFC41B1B" />
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Grid Background="{TemplateBinding Background}">
                            <ContentPresenter x:Name="MyContentPresenter"
                                              HorizontalAlignment="Center"
                                              VerticalAlignment="Center"
                                              Content="{TemplateBinding Content}" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsEnabled" Value="false">
                    <Setter Property="Foreground" Value="#7d7f74" />
                    <Setter Property="Background" Value="#31302c" />
                </Trigger>
                <Trigger Property="IsKeyboardFocused" Value="true">
                    <Setter Property="Foreground" Value="Goldenrod" />
                </Trigger>
                <Trigger Property="IsMouseOver" Value="true">
                    <Setter Property="Foreground" Value="Goldenrod" />
                </Trigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="ButtonTextBlock" TargetType="TextBlock">
            <Setter Property="Foreground" Value="White" />
            <Setter Property="FontFamily" Value="Trebuchet" />
            <Setter Property="FontSize" Value="14" />
            <Setter Property="Foreground" Value="White" />
            <Setter Property="Background" Value="#000000FF" />
            <Setter Property="TextAlignment" Value="Center" />
            <Setter Property="Width" Value="95" />
            <Setter Property="Padding" Value="5" />
            <Setter Property="Margin" Value="0,8,0,8" />
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="true">
                    <Setter Property="Foreground" Value="Goldenrod" />
                </Trigger>
                <Trigger Property="IsEnabled" Value="false">
                    <Setter Property="Foreground" Value="#7d7f74" />
                    <Setter Property="Background" Value="#31302c" />
                </Trigger>
            </Style.Triggers>
        </Style>
        <Style x:Key="TextBoxTextBlock" TargetType="TextBlock">
            <Setter Property="Foreground" Value="White" />
            <Setter Property="FontFamily" Value="Trebuchet" />
            <Setter Property="FontSize" Value="14" />
            <Setter Property="Foreground" Value="White" />
            <Setter Property="Background" Value="#000000FF" />
            <Setter Property="TextAlignment" Value="Center" />
            <Setter Property="Width" Value="80" />
            <Setter Property="Padding" Value="5" />
            <Setter Property="Margin" Value="0,8,0,8" />
            <Setter Property="Height" Value="Auto" />
            <Style.Triggers>
                <Trigger Property="IsEnabled" Value="false">
                    <Setter Property="Foreground" Value="#7d7f74" />
                    <Setter Property="Background" Value="#31302c" />
                </Trigger>
            </Style.Triggers>
        </Style>


And:

XML
<Button x:Name="buttonReset"
                   Click="buttonReset_Click"
                   Style="{StaticResource ButtonStyle}">
               <TextBlock Style="{StaticResource ButtonTextBlock}">
                   <Run Text="Reset" />
                   <LineBreak /><Run Text="alles" />
               </TextBlock>
           </Button>


code behind:

C#
private void buttonReset_Click(object sender, RoutedEventArgs e)
      {
          if (!buttonReset.IsKeyboardFocused) return;
          ResetAll();
          buttonNwOpdrNr.IsEnabled = true;
          buttonZoeken.IsEnabled = true;
      }


What can cause this behavior ?

Thanks in advance,

Groover
0200 A9 23
0202 8D 01 80
0205 00

AnswerRe: Enter key invokes button click Pin
Mycroft Holmes23-Jul-16 14:28
professionalMycroft Holmes23-Jul-16 14:28 
GeneralRe: Enter key invokes button click Pin
GrooverFromHolland24-Jul-16 0:19
GrooverFromHolland24-Jul-16 0:19 
GeneralRe: Enter key invokes button click Pin
Mycroft Holmes24-Jul-16 14:34
professionalMycroft Holmes24-Jul-16 14:34 
QuestionUsing negative height margin values to properly vertically align a control Pin
Stephen Holdorf22-Jul-16 14:22
Stephen Holdorf22-Jul-16 14:22 
AnswerRe: Using negative height margin values to properly vertically align a control Pin
Stephen Holdorf23-Jul-16 4:50
Stephen Holdorf23-Jul-16 4:50 
GeneralRe: Using negative height margin values to properly vertically align a control Pin
Stephen Holdorf23-Jul-16 9:47
Stephen Holdorf23-Jul-16 9:47 
QuestionList Control Question Pin
Kevin Marois21-Jul-16 14:36
professionalKevin Marois21-Jul-16 14:36 
AnswerRe: List Control Question Pin
Gerry Schmitz22-Jul-16 11:18
mveGerry Schmitz22-Jul-16 11:18 
QuestionKeeping correct layout when browser is resized Pin
Stephen Holdorf17-Jul-16 3:37
Stephen Holdorf17-Jul-16 3:37 
AnswerRe: Keeping correct layout when browser is resized Pin
Gerry Schmitz18-Jul-16 6:19
mveGerry Schmitz18-Jul-16 6:19 
QuestionStyling a Drag and Drop Items behavior in a WPF ListView Pin
Kenneth Haugland13-Jul-16 5:43
mvaKenneth Haugland13-Jul-16 5:43 
QuestionShort way defining a property with the NotifyPropertyChanged() call Pin
Mc_Topaz9-Jul-16 9:26
Mc_Topaz9-Jul-16 9:26 
AnswerRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Mycroft Holmes9-Jul-16 11:35
professionalMycroft Holmes9-Jul-16 11:35 
AnswerRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Mc_Topaz9-Jul-16 11:49
Mc_Topaz9-Jul-16 11:49 
AnswerRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Super Lloyd10-Jul-16 14:31
Super Lloyd10-Jul-16 14:31 
AnswerRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Pete O'Hanlon10-Jul-16 21:23
mvePete O'Hanlon10-Jul-16 21:23 
AnswerRe: Short way defining a property with the NotifyPropertyChanged() call Pin
Gerry Schmitz11-Jul-16 6:04
mveGerry Schmitz11-Jul-16 6:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.