Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 使用InvokeCommandAction MVVM传递参数_Wpf_Mvvm_Devexpress Wpf - Fatal编程技术网

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}}}" />

。。。 注:

  • 我无法使用MVVM灯光(GalaSoft)
  • 互动并没有让我采取行动

    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框架,则说明如何实现自定义触发器操作,手动将事件参数传递给命令