0

我得到了以下 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>

它是一个绑定到 mvvm 中的字符串的文本框。问题是当我在第一个字母处按“shift + a character”时,事件不会被触发。当我按下大写锁定+任何字符时,该事件将照常触发。当我按键盘上的任何字符时,它也可以工作。

任何人都可以帮助我吗?

提前谢谢,

编辑:Geert建议后的解决方案:

在 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>

在 ViewModel 中(使用 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);
}
4

1 回答 1

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

于 2013-09-23T16:20:04.133 回答