【发布时间】:2011-10-04 16:57:58
【问题描述】:
我使用一项服务来管理对话框,该服务运行良好并将可视化细节与我的视图模型分离。
我的代码(如下)可以轻松地将对话框窗口所有者设置为主窗口,但我真正想要做的是将它放在图形项(即按钮等)旁边那叫它。
有人对此有 MVVM 解决方案吗?
干杯,
浆果
// helper to create and prep windows in WPF
private Window _createWindow(
string key, object dataContext, bool setOwnerToCurrentMainWindow,
EventHandler<UICompletedEventArgs> completedProc, bool isModal)
{
var win = _registrationService.CreateRegisteredType<Window>(key);
win.DataContext = dataContext;
...
if (setOwnerToCurrentMainWindow)
win.Owner = Application.Current.MainWindow;
...
return win;
}
【问题讨论】: