public void Create <TViewModel>(ViewModelBase ownerViewModel = null, bool isDialog = false) where TViewModel : ViewModelBase, new() { var viewModel = new TViewModel(); var window = new DefaultWindow { DataContext = viewModel, SizeToContent = SizeToContent.WidthAndHeight, Owner = GetViewByViewModel(ownerViewModel), WindowStartupLocation = WindowStartupLocation.CenterOwner, }; if (ownerViewModel == null) { window.WindowStartupLocation = WindowStartupLocation.CenterScreen; } window.Loaded += viewModel.OnLoaded; window.Closing += viewModel.OnClosing; Application.Current.Dispatcher.Invoke(() => { if (!isDialog) { window.Show(); } else { window.ShowDialog(); } }); }
public void Load(IBootContext b) { if (b.Contains("LocalizeBootloader")) { b.Requeue(); return; } MainWindow = new DefaultWindow() { //WindowStartupLocation = WindowStartupLocation.CenterScreen, //WindowState = WindowState.Maximized }; MainWindow.Closing += (sender, args) => System.Windows.Application.Current.Shutdown(); MainWindow.Show(); _info.Version = Assembly.GetCallingAssembly().GetName().Version; InitializeCultures(); if (Updater != null) { Updater.CheckVersion(); if (Updater.NewVersionFound) { var updaterView = new ApplicationUpdateView { DataContext = Updater }; // TODO : updaterView.ShowDialog(); if (Updater.Updated) { System.Windows.Application.Current.Shutdown(); return;; } } } ViewModel = _getVm(); var w = _mvvm.MainContext.GetView(ViewModel, MainViewMode); _menu.RegisterMenu("file", "{File}", null, null); _menu.RegisterMenu("data", "{Data}", null, null); _menu.RegisterMenu("param", "{Parameters}", null, null); _menu.RegisterMenu("tools", "{Tools}", null, null); _menu.RegisterMenu("help", "{_?}", null, null); _menu.RegisterMenu("file/exit", "{Exit}", ViewModel.Exit, null); MainWindow.Content = w; return; }
private void Button_Click(object sender, RoutedEventArgs e) { DefaultWindow dw = new DefaultWindow(); Edit edit = new Edit(); dw.Content = edit.Content; dw.Title = edit.Title; dw.Owner = Window.GetWindow(this); dw.Show(); }
private void ShowPage(string url) { if (isMainWindowShow && mainWindow != null) { var vm = mainWindow.DataContext as MainViewModel; if (vm != null) { vm.Uri = url; mainWindow.Show(); mainWindow.Activate(); } } else { CreateMainWindow(url); } }