1

我想根据一些业务逻辑禁用单元格/列。我正在使用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}}}" />

... 笔记:

  1. 我不能使用MVVM 灯( GalaSoft )。
  2. 交互没有给我 CallMethodAction。

    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
    <ei:CallMethodAction
    
  3. 我不想传递ViewModel(例如SelectedItem)的绑定属性

  4. 使用DevExpress GridControl
4

1 回答 1

3

考虑使用 DevExpress MVVM 框架,您可以在其中将事件参数作为参数传递给视图模型:

<dxmvvm:Interaction.Behaviors>
    <dxmvvm:EventToCommand EventName="ShowingEditor" Command="{Binding ShowingEditorCommand}" PassEventArgsToCommand="True" />
</dxmvvm:Interaction.Behaviors>

甚至在将 EventArgs 对象传递给您的命令之前,使用 EventArgsConverter 属性指定的转换器进行转换。

查看EventToCommand文章以了解更多信息。

PS 如果由于某种原因您不能使用 DevExpress MVVM 框架,这篇文章描述了如何实现自定义 TriggerAction,手动将事件参数传递给命令。

于 2015-08-10T13:11:13.510 回答