0
如果用戶按下輸入,但以下模板可以正常工作,但我也希望在TextBox
失去焦點時觸發該命令。我怎樣才能做到這一點?如何在WPF中失去焦點時觸發文本框命令?
以下是我TextBox
模板
<DataTemplate x:Key="PhantomNameEditTemplate">
<TextBox Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}">
<TextBox.InputBindings>
<KeyBinding Command="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=DataGrid}, Path=DataContext.RenameCommand}" CommandParameter="{Binding}" Key="Enter" />
</TextBox.InputBindings>
</TextBox>
</DataTemplate>
謝謝,我沒有使用MVVM框架,並且工作完美。 – Bob 2014-09-24 14:40:16