【发布时间】:2014-01-30 22:14:49
【问题描述】:
这是我的第一个 MVVM 应用程序,我想知道在用户完成OpenFileDialog 后如何切换到另一个视图。
目前使用的改变视图技术是从here借来的。
换句话说,如何调用:
private void ExecuteGridViewCommand()
{
CurrentViewModel = MainViewModel._gridViewModel;
}
由于 Dialog 不是 XAML 控件,因此我无法跟踪用户单击 Dialog 的“打开”按钮的时间。
private static ViewModelBase _currentViewModel;
public ViewModelBase CurrentViewModel
{
get { return _currentViewModel; }
set
{
if (_currentViewModel != value)
{
_currentViewModel = value;
OnPropertyChanged();
}
}
}
【问题讨论】:
-
你能展示你的
CurrentViewModel属性吗? -
@AnatoliiGabuza 你能详细说明一下吗?
-
我的意思是展示你的属性 setter 和 getter 里面的内容。
-
谢谢。我将属性代码添加到主帖中。我要做的是在对话框关闭后添加一个 bool 属性并将其绑定到 xaml,因此当它完成/为真时,我可以调用 ExcuteGridView 方法。不确定这种情况是否可行,但正在尝试。
标签: c# wpf mvvm openfiledialog