public CustomMessageBox( string caption, CustomMessageBoxIcon icon = CustomMessageBoxIcon.Default, CustomMessageBoxButtons buttons = CustomMessageBoxButtons.None, List <string> messageRows = null, string prompt = null, CustomMessageBoxPromptValidation promptValidationMode = CustomMessageBoxPromptValidation.None, CustomMessageBoxFocus controlFocus = CustomMessageBoxFocus.Default) { DataContext = this; InitializeComponent(); if (DesignerProperties.GetIsInDesignMode(this)) { } else { // ToDo: Evil Hack to have the cake (see actual design in design mode) and eat it too (have different styles at runtime) this.Resources = null; } int currentIndex = 0; this.Title = caption; this.promptValidationMode = promptValidationMode; this.controlFocus = controlFocus; var rowCaption = new RowDefinition(); rowCaption.Height = GridLength.Auto; ContentGrid.RowDefinitions.Add(rowCaption); var captionTextBox = new System.Windows.Controls.TextBlock(); var captionStyle = (Style)FindResource("VersionName_TextBox_Style"); if (captionStyle != null) { captionTextBox.Style = captionStyle; } captionTextBox.Text = caption; ContentGrid.InsertAt(captionTextBox, 0, currentIndex); currentIndex++; switch (icon) { case CustomMessageBoxIcon.Information: { var informationStyle = (Style)FindResource("CustomMessageBoxInformationIconStyle"); if (informationStyle != null) { DialogImage.Style = informationStyle; } break; } case CustomMessageBoxIcon.Question: { var questionStyle = (Style)FindResource("CustomMessageBoxQuestionIconStyle"); if (questionStyle != null) { DialogImage.Style = questionStyle; } break; } case CustomMessageBoxIcon.Error: { var errorStyle = (Style)FindResource("CustomMessageBoxErrorIconStyle"); if (errorStyle != null) { DialogImage.Style = errorStyle; } break; } case CustomMessageBoxIcon.Default: { var defaultStyle = (Style)FindResource("CustomMessageBoxDefaultIconStyle"); if (defaultStyle != null) { DialogImage.Style = defaultStyle; } break; } } var textblockStyle = (Style)FindResource("CustomMessageBox_TextBlock_Style"); if (messageRows != null && messageRows.Any()) { foreach (var messgeRow in messageRows) { var rowDefinition = new RowDefinition(); rowDefinition.Height = GridLength.Auto; ContentGrid.RowDefinitions.Add(rowDefinition); var tempTextBox = new System.Windows.Controls.TextBlock(); if (textblockStyle != null) { tempTextBox.Style = textblockStyle; } tempTextBox.Text = messgeRow; ContentGrid.InsertAt(tempTextBox, 0, currentIndex); currentIndex++; } } if (prompt != null) { var promptRow = new RowDefinition(); promptRow.Height = GridLength.Auto; ContentGrid.RowDefinitions.Add(promptRow); promptTextBox = new System.Windows.Controls.TextBox(); var promptStyle = (Style)FindResource("MainWindowTextBoxStyle"); if (promptStyle != null) { promptTextBox.Style = promptStyle; } promptTextBox.Name = "DialogPromptTextBox"; promptTextBox.IsEnabled = true; promptTextBox.IsReadOnly = false; promptTextBox.TextChanged += PromptTextBox_TextChanged; promptTextBox.Text = prompt; ContentGrid.InsertAt(promptTextBox, 0, currentIndex); if (controlFocus == CustomMessageBoxFocus.Prompt) { promptTextBox.Focus(); promptTextBox.Select(0, prompt.Length); } currentIndex++; } if (buttons != CustomMessageBoxButtons.None) { var tempButton = new SvgImageButton1(); var buttonStyle = (Style)FindResource("SvgAcceptButton"); if (buttonStyle != null) { tempButton.Style = buttonStyle; } tempButton.HorizontalAlignment = HorizontalAlignment.Right; tempButton.Click += OkButton_Click; tempButton.IsDefault = true; DialogGrid.InsertAt(tempButton, 1, 3); if (controlFocus == CustomMessageBoxFocus.Ok) { tempButton.Focus(); } if (buttons == CustomMessageBoxButtons.OkAndCancel) { var cancelButton = new SvgImageButton1(); var cancelButtonStyle = (Style)FindResource("SvgCancelButton"); if (cancelButtonStyle != null) { cancelButton.Style = cancelButtonStyle; } cancelButton.HorizontalAlignment = HorizontalAlignment.Left; cancelButton.Click += CancelButton_Click; DialogGrid.InsertAt(cancelButton, 0, 3); if (controlFocus == CustomMessageBoxFocus.Cancel) { cancelButton.Focus(); } } currentIndex++; } }