我正在实现一个IDialogService
。这将会从我的ViewModel中调用,但是ViewModel并不知道View。
为了确定传递给ShowDialog
的Owner,最好的方法是什么?
如果可以的话,最好避免注册哪个View绑定到哪个ViewModel。
如果能有帮助的话,我正在使用Prism(v6)。
window.Owner = Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);
window.Owner = Application.Current.MainWindow;
怎么样? - JoseMainWindow
,无论调用窗口如何。然后你可以尝试Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);
。 - Jose