我该如何将从ViewModel声明、初始化和打开的窗口设置为所有者?
以下是代码:
public class ViewModel : INotifyPropertyChanged
{
// declaration
static nextWindow nw;
...
public ICommand OpenNextWindow { get { return new RelayCommand(OpenNextWindowExecute, CanOpenNextWindowExecute); } }
bool CanOpenNextWindowExecute(object parameter)
{
return true;
}
void OpenNextWindowExecute(object parameter)
{
nw = new nextWindow();
nw.WindowStartupLocation = WindowStartupLocation.CenterScreen;
// Set this window as owner before showing it...
nw.Show();
}
}
在 nextWindow 的代码后台文件中,我可以使用以下代码将 nextWindow 设置为所有者:
nw.Owner = this;
我该如何从视图模型实现它?