/// <summary>
        /// Shows a dialog.
        /// </summary>
        /// <remarks>
        /// The dialog used to represent the ViewModel is retrieved from the registered mappings.
        /// </remarks>
        /// <param displayName="ownerViewModel">
        /// A ViewModel that represents the owner window of the dialog.
        /// </param>
        /// <param displayName="viewModel">The ViewModel of the new dialog.</param>
        /// <returns>
        /// A nullable value of type bool that signifies how a window was closed by the user.
        /// </returns>
        public bool?ShowDialog(object ownerViewModel, object viewModel)
        {
            Type dialogType =
                windowViewModelMappings.GetWindowTypeFromViewModelType(viewModel.GetType());

            return(ShowDialog(ownerViewModel, viewModel, dialogType));
        }
Beispiel #2
0
        private Window CreateDialog(object ownerViewModel, object viewModel)
        {
            Type   dialogType = _windowViewModelMappings.GetWindowTypeFromViewModelType(viewModel.GetType());
            var    dialog     = (Window)Activator.CreateInstance(dialogType);
            Window owner      = FindOwnerWindow(ownerViewModel);

            if (dialog != owner)
            {
                dialog.Owner = owner;
            }
            else
            {
                dialog.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            }
            dialog.DataContext = viewModel;
            return(dialog);
        }