如何在mvvm wpf中创建处理程序事件

时间:2016-06-10 11:17:16

标签: wpf mvvm

当我们在wpf中遵循MVVM模式时,如何为Event Setter处理程序创建Command。我的xmal代码如下:

<ListBox.ItemContainerStyle>
         <Style TargetType="ListBoxItem">
             <EventSetter Event="Drop" Handler="horizontalListBox2_Drop" />
         </Style>
    </ListBox.ItemContainerStyle>

1 个答案:

答案 0 :(得分:0)

您不需要跟随MVVM的命令,您也可以使用该处理程序和代码并在VM上调用某些内容。但是你可以创建一个markup extension来为你做这件事,而不需要那样做。这是an example where i create an extension to filter a collection的方式。如果你没有复杂的参数,你当然也可以使用卷曲符号。

相关问题