我是新來的MVVM,並試圖找出如何關閉ChildWindow與傳統取消使用MVVM光工具包鍵取消按鈕ChildWindow。如何關閉使用MVVM光工具包
在我ChildWindow(StoreDetail.xaml),我有:
<Button x:Name="CancelButton" Content="Cancel" Command="{Binding CancelCommand}" />
在我的視圖模型(ViewModelStoreDetail.cs),我有:
public ICommand CancelCommand { get; private set; }
public ViewModelStoreDetail()
{
CancelCommand = new RelayCommand(CancelEval);
}
private void CancelEval()
{
//Not sure if Messenger is the way to go here...
//Messenger.Default.Send<string>("ClosePostEventChildWindow", "ClosePostEventChildWindow");
}
將在什麼地方SaveSettings = ...去? – admiral142 2014-07-31 20:26:39
在ViewModel構造函數中。一個完整的例子可以在這裏找到(http://msdn.microsoft.com/en-us/magazine/dn237302.aspx)以及Command,RelayCommand和EventToCommand文檔。 – DanteTheEgregore 2014-07-31 21:56:33