Wpf 使用InvokeCommandAction MVVM传递参数
我想基于某些业务逻辑禁用单元格/列。我正在使用Wpf 使用InvokeCommandAction MVVM传递参数,wpf,mvvm,devexpress-wpf,Wpf,Mvvm,Devexpress Wpf,我想基于某些业务逻辑禁用单元格/列。我正在使用ShowingEditor事件和ShowingEditorEventArgs取消它。传递ShowingEditorEventArgs将是非常好的。我能够作为参数传递整个网格。使用下面的代码。但我只想传递所选单元格的ShowingEditorEventArgs。可能是一些相关的资源绑定帮助了我 <dxg:GridControl x:Name="grid" > <dxg:GridControl.View&
ShowingEditor
事件和ShowingEditorEventArgs
取消它。传递ShowingEditorEventArgs将是非常好的。我能够作为参数传递整个网格。使用下面的代码。但我只想传递所选单元格的ShowingEditorEventArgs
。可能是一些相关的资源绑定帮助了我
<dxg:GridControl x:Name="grid" >
<dxg:GridControl.View>
<dxg:TableView Name="view" ShowingEditor="view_ShowingEditor">
<i:Interaction.Triggers>
<i:EventTrigger EventName="ShowingEditor">
<i:InvokeCommandAction Command="{Binding ShowingEditorCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type dxg:GridControl}}}" />
。。。
注:
xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
<ei:CallMethodAction
xmlns:ei=”http://schemas.microsoft.com/expression/2010/interactions"
考虑使用DevExpress MVVM框架,在该框架中,您可以将事件参数作为参数传递给视图模型:
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="ShowingEditor" Command="{Binding ShowingEditorCommand}" PassEventArgsToCommand="True" />
</dxmvvm:Interaction.Behaviors>
甚至可以在使用EventArgsConverter属性指定的转换器将EventArgs对象传递给命令之前对其进行转换
看看这篇文章,了解更多信息
注意:如果由于某种原因无法使用DevExpress MVVM框架,则说明如何实现自定义触发器操作,手动将事件参数传递给命令