public static T CreateDialog <T>() where T : class { var window = new HostWindow(); var result = GlobalContainer.Resolve <IHostWindowViewModel>(); result.Content = GlobalContainer.Resolve <T>(); window.DataContext = result; window.Owner = App.Current.MainWindow; window.ShowDialog(); return(result.Content as T); }
public static bool?CreateDialog <T>(T viewModel) where T : class { var window = new HostWindow(); var hostViewModel = GlobalContainer.Resolve <IHostWindowViewModel>(); hostViewModel.Content = viewModel; window.DataContext = hostViewModel; window.Owner = App.Current.MainWindow; if (viewModel is IClosable) { (viewModel as IClosable).OnClose = (result) => { window.DialogResult = result; window.Close(); } } ; return(window.ShowDialog()); } }