MVVM LightToolkit和WPF Datagrid AutoGeneratingColumn事件

时间:2015-03-26 14:04:31

标签: c# wpf mvvm-light

是否可以使用MVVMLight Toolkits EventToCommand方法处理Datagrid的AutoGeneratingColumn事件?我尝试了以下方法,但它似乎不起作用:

<i:Interaction.Triggers>
                <i:EventTrigger EventName="AutoGeneratingColumn">
                    <mvvm:EventToCommand Command="{Binding TestCommand}">  </mvvm:EventToCommand>
                </i:EventTrigger>
</i:Interaction.Triggers>

1 个答案:

答案 0 :(得分:0)

是的。

我建议您按照下面的说明设置您的Xaml和命令签名。

<强> XAML

<i:Interaction.Triggers>
    <i:EventTrigger EventName="AutoGeneratingColumn">
        <mvvm:EventToCommand Command="{Binding TestCommand}" PassEventArgsToCommand="True" />
    </i:EventTrigger>
</i:Interaction.Triggers>

C# - 在您的DataContext(ViewModel)

public void Test(AutoGeneratingColumnEventArgs e)
{
    // handle however you need to here
}