mainViewと他の2つのビュー(ユーザーコントロール)を使用してサンプルを作成しました。子ビューに「閉じる」ボタンを配置しましたが、そのビューを閉じたいと思います。そのボタンにコマンドが添付されており、閉じるを押すと、ViewModelLocatorにそれをクリーンアップするように依頼します。
しかし-ビューはまだ表示されています..私が間違っているのは何ですか?mvvm-lightでuserControlビューを閉じるにはどうすればよいですか?
private RelayCommand _closeCommand;
public RelayCommand CloseCommand
{
get
{
if (_closeCommand == null)
{
_closeCommand = new RelayCommand(()=>
ViewModelLocator.ClearAllChannels(),
);
}
return _closeCommand;
}
}
ViewModelLocator関数:
public static void ClearAllChannels()
{
if (_allChannels != null)
{
_allChannels.Cleanup();
_allChannels = null;
}
}