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