WPF MVVM在viewModel中关闭view界面

ViewModel中添加  public Action CloseAction { get; set; }

view中xaml.cs文件中添加

var viewModel = IocManager.Instance.Resolve<LoginWindowViewModel>();
DataContext = viewModel;
viewModel.CloseAction = Close;

然后在ViewModel中需要关闭的地方加CloseAction();

posted @ 2019-01-04 10:54  儿歌三百首  阅读(542)  评论(0编辑  收藏  举报