public QuickSearch(bool isQuickSearch) { InitializeComponent(); this.DataContext = new SearchViewModel(isQuickSearch); Window parentWindow = Window.GetWindow(this); if (parentWindow != null) { FactoryService.Register(this.DataContext as ViewModelBase, parentWindow); } }
public Connect() { InitializeComponent(); this.DataContext = new ConnectViewModel(); Window parentWindow = Window.GetWindow(this); if (parentWindow != null) { FactoryService.Register(this.DataContext as ViewModelBase, parentWindow); } }
private static void openWindowHandler(WindowFactoryData data) { Window window = null; object viewModel = null; switch (data.WindowType) { case WindowClassType.MainWindow: window = new MainWindow(); viewModel = new MainWindowViewModel(); break; case WindowClassType.Catalog: window = new Catalog(); viewModel = new CatalogViewModel(data.DataAgggregator); break; default: break; } if (window == null || viewModel == null) { return; } window.DataContext = viewModel; FactoryService.Register(viewModel as ViewModelBase, window); // Attemps to find a parent window based on what ViewModel sent the request. Window parentWindow = FactoryService.GetWindowReference(data.CallingViewModel); if (parentWindow != null) { window.Owner = parentWindow; } if (data.Modal) { window.ShowDialog(); } else { window.Show(); } }