/// <summary> /// Shows a modal window and sets the resulting output in the /// <see cref="ModalSettings"/> which is returned to the calling code. /// </summary> /// <param name="modalSettings">The <see cref="ModalSettings"/>.</param> public void ShowModal(ModalSettings modalSettings) { var viewType = Type.GetType(modalSettings.View); var resolvedView = container.Resolve(viewType, modalSettings.View); var view = (ModalViewBase)resolvedView; var viewModelType = Type.GetType(modalSettings.ViewModel); var viewModel = container.Resolve(viewModelType, modalSettings.ViewModel); ((ModalViewModel)viewModel).Publish(modalSettings.Parameters); view.RegisterDialogEventsHandlers((ModalViewModel)viewModel); view.DataContext = viewModel; var window = new ModalViewHost(view); window.Icon = new BitmapImage(new Uri(@"pack://application:,,/Images/Origin.png", UriKind.RelativeOrAbsolute)); window.Title = modalSettings.Title ?? String.Empty; window.Height = modalSettings.Height; window.Width = modalSettings.Width; var result = window.ShowDialog(); modalSettings.Result = result; modalSettings.Output = ((ModalViewModel)viewModel).Output; }
private void OpenWindow(object param) { var modalSettings = new ModalSettings() { Title = WindowTitle, View = "DevelopmentInProgress.ExampleModule.View.ExampleModalView,DevelopmentInProgress.ExampleModule", ViewModel = "DevelopmentInProgress.ExampleModule.ViewModel.ExampleModalViewModel,DevelopmentInProgress.ExampleModule", Height = 700, Width = 700 }; modalSettings.Parameters.Add("ModalParameter", WindowParameter); ShowModal(modalSettings); }
/// <summary> /// Handles the ShowModalWindow event raised by the view model. /// </summary> /// <param name="sender">The view model.</param> /// <param name="e">Modal settings.</param> protected void ShowModalWindow(object sender, ModalSettings e) { ViewContext.ModalNavigator.ShowModal(e); }
/// <summary> /// Raises the <see cref="ShowModalWindow"/> event which is handled on the view. /// </summary> /// <param name="modalSettings">Details of the modal form to display.</param> protected void ShowModal(ModalSettings modalSettings) { var showModalWindow = ShowModalWindow; if (showModalWindow != null) { showModalWindow(this, modalSettings); } }