我在我的WPF应用程序中使用MVVMCross,我想在 GUI 中提供一个Close(或Exit)按钮来关闭整个应用程序。有没有使用MVVMCross功能的简单方法来做到这一点?
我尝试了以下方法MainViewModel
:
public class MainViewModel : MvxViewModel
{
private MvxCommand _closeCommand;
public MvxCommand CloseCommand {
get {
return _closeCommand ?? (_closeCommand = new MvxCommand(DoClose));
}
}
public void DoClose() {
Close(this);
}
}
不幸的是,无济于事。DoClose
当我按下已绑定到 的按钮时,该方法会被调用CloseCommand
,但视图模型(和相应的视图)无法关闭,即使 WPFApp
StartupUri
设置为MainView
.