在WPF的
我们还可以使用
什么是它们之间的区别?何时使用哪种?
更新:
我已经注意到以下情况中的差异:
- 我有一个文本框,如果文本框为空,则使用IValudationRule进行验证。 - 我添加了MultiDataTrigger条件,当Validation.HasError等于true时,将保存按钮的IsEnabled属性设置为false。 - 使用Button Command一切正常,但使用EventTrigger却无法工作。
这是什么原因?
Button
中,我们有一个可以绑定到ICommand
的Command
参数。<Button Command="{Binding SomeCommand}"/>
我们还可以使用
InvokeCommandAction
与 EventTriggers
来触发一个 ICommand
。<Button>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<i:InvokeCommandAction Command="{Binding SomeCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
什么是它们之间的区别?何时使用哪种?
更新:
我已经注意到以下情况中的差异:
- 我有一个文本框,如果文本框为空,则使用IValudationRule进行验证。 - 我添加了MultiDataTrigger条件,当Validation.HasError等于true时,将保存按钮的IsEnabled属性设置为false。 - 使用Button Command一切正常,但使用EventTrigger却无法工作。
这是什么原因?