我想根据一些业务逻辑禁用单元格/列。我正在使用 ShowingEditor
事件和 ShowingEditorEventArgs
取消它。路过ShowingEditorEventArgs
会很棒。我可以将整个网格作为参数传递。使用下面的代码。但我只想通过ShowingEditorEventArgs
选定的单元格。可能是一些相关的资源绑定(bind)帮助我在这里。
<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
ViewModel
的绑定(bind)属性(例如 SelectedItem
) 最佳答案
考虑使用 DevExpress MVVM 框架,您可以在其中将事件参数作为参数传递给 View 模型:
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="ShowingEditor" Command="{Binding ShowingEditorCommand}" PassEventArgsToCommand="True" />
</dxmvvm:Interaction.Behaviors>
甚至在将 EventArgs 对象传递给您的命令之前使用 EventArgsConverter 属性指定的转换器进行转换。
看看EventToCommand文章以了解更多信息。
附言如果由于某种原因不能使用 DevExpress MVVM 框架,this post描述了如何实现自定义 TriggerAction 手动将事件参数传递给命令。
关于wpf - 使用 InvokeCommandAction MVVM 传递参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31455857/