0

i got the following XAML:

<TextBox TextWrapping="Wrap"
      Width="300"
          Text="{Binding SearchText, Mode=TwoWay,
                    UpdateSurceTrigger=PropertyChanged}"
          VerticalContentAlignment="Center"  
          ToolTip="Suchbegriff eingeben.">
     <i:Interaction.Triggers>
         <i:EventTrigger EventName="TextChanged">
              <catel:EventToCommand Command="{Binding SearchTxt_TextChangedCmd}" 
                               DisableAssociatedObjectOnCannotExecute="False"/>
         </i:EventTrigger>    
     </i:Interaction.Triggers>
 </TextBox>

It's a textbox which is bound to a string in mvvm. The problem is when i press "shift + a character" at the first letter then the event is not fired. When i press caps lock + any character, then the event will be fired as usual. It alsow works when i press any character on the keyboard.

Can anyone help me please?

Thx in advance,

Edit: Solution after the suggestion of Geert:

In the view.xaml:

<TextBox Height="31" 
         HorizontalAlignment="Right" 
         Margin="0,59,20,0" 
         Name="textBox2" 
         VerticalAlignment="Top" 
         Width="282"
         Text="{Binding BehaviorText, Mode=TwoWay}">
    <i:Interaction.Behaviors>
        <catel:UpdateBindingOnTextChanged UpdateDelay="200" />
    </i:Interaction.Behaviors>
</TextBox>

In the ViewModel (using Catel):

public String BehaviorText
{
    get { return GetValue<String>(BehaviorTextProperty); }
    set { SetValue(BehaviorTextProperty, value); }
}


public static readonly PropertyData BehaviorTextProperty =
    RegisterProperty("BehaviorText", typeof(String), null, (sender, e) => ((MainWindowViewModel)sender).OnUpdateBindingOnTextChanged());

private void OnUpdateBindingOnTextChanged()
{
    Console.WriteLine(BehaviorText);
}
Termininja
  • 6,620
  • 12
  • 48
  • 49
Benjamin Martin
  • 576
  • 1
  • 8
  • 27

1 Answers1

0

Use the UpdateBindingOnTextChanged behavior instead. If that doesn't fit your needs, please create a repro and upload it at https://catelproject.atlassian.net

Geert van Horrik
  • 5,689
  • 1
  • 18
  • 32