1
我有一个WPF按钮,当前有两个函数我想要放入MVVM模式。如果单击时满足条件,它将打开我们动态构建的上下文菜单,否则我们只需执行另一个函数。将按钮点击事件的WPF上下文菜单更改为MVVM
private void Button_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
{
if (MyTest())
{
Button b = sender as Button;
ContextMenu contextMenu = MyContextMenuBuilder();
contextMenu.PlacementTarget = b;
contextMenu.Placement = System.Windows.Controls.Primitives.PlacementMode.Bottom;
contextMenu.IsOpen = true;
}
else
{
MyOtherFunction();
}
}
}
我该如何MV-VM这个代码,因为VM不知道放置菜单的按钮和菜单本身是否打开它?
其中'INotifyPropertyChanged'在'ButtonAnnotation'? – Svisstack 2011-01-19 22:28:57