public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (this.BindableConverterParameter != null && this.BindableConverterParameter is IMessageBoxModel && value is NotificationButtons) { NotificationButtons valueEnum = (NotificationButtons)value; IMessageBoxModel parameterEnum = (IMessageBoxModel)this.BindableConverterParameter; return(valueEnum == parameterEnum.DefaultButton); } return(false); }
/// <summary> /// Displays a message box in front of the specified window. The message box is configured like specified in the <see cref="IMessageBoxModel"/> and returns a result. /// </summary> /// <param name="owner">A <see cref="Window"/> that represents the owner window of the message box.</param> /// <param name="messageBoxModel">An <see cref="IMessageBoxModel"/> that configures the appearance and behavior of the message box.</param> /// <returns>A <see cref="MessageBoxResult"/> value that specifies which message box button is clicked by the user.</returns> public static MessageBoxResult Show(Window owner, IMessageBoxModel messageBoxModel) { var messageBox = new MessageBoxWindow { Owner = owner, ViewModel = messageBoxModel, }; messageBox.ShowDialog(); return(messageBoxModel.Result); }
/// <summary> /// Displays a message box that is configured like specified in the <see cref="IMessageBoxModel"/> and that returns a result. /// </summary> /// <param name="messageBoxModel">An <see cref="IMessageBoxModel"/> that configures the appearance and behavior of the message box.</param> /// <returns>A <see cref="MessageBoxResult"/> value that specifies which message box button is clicked by the user.</returns> public static MessageBoxResult Show(IMessageBoxModel messageBoxModel) { Window activeWindow = Application.Current?.Windows.OfType <Window>().FirstOrDefault(x => x.IsActive); return(Show(activeWindow, messageBoxModel)); }