private PictoMsgBox(string title, string message, PictoMsgBoxButton bType) { InitializeComponent(); DataContext = this; Owner = Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive); Header = title; Message = message; SetButtonType(bType); }
private void SetButtonType(PictoMsgBoxButton bType) { switch (bType) { case PictoMsgBoxButton.OK: B_Deny.Visibility = Visibility.Collapsed; B_Accept.SetValue(Grid.ColumnSpanProperty, 2); break; case PictoMsgBoxButton.YesNo: break; default: return; } }
/// <summary> /// Displays a message box that has a message, a title and the specified buttons /// </summary> /// <param name="title">The title to be displayed</param> /// <param name="message">The message to be displayes</param> /// <param name="button">The type of buttons to be displayed</param> /// <returns>Return value depends on what kind of buttons was pressed</returns> public static bool?ShowMessage(string title, string message, PictoMsgBoxButton button) { return(new PictoMsgBox(title, message, button).ShowDialog()); }