/// <summary> /// Method is executed when TestMsgBoxParameters command is invoked. /// </summary> private async void TestMsgBoxParametersAsync_Executed() { MsgBoxImage image; image = this.MessageImageSelected.EnumKey; // Set the current culture and UI culture to the currently selected languages Thread.CurrentThread.CurrentCulture = new CultureInfo(this.ButtonLanguageSelected.BCP47); Thread.CurrentThread.CurrentUICulture = new CultureInfo(this.ButtonLanguageSelected.BCP47); var msg = GetService <IContentDialogService>().MsgBox; MsgBoxResult result = await msg.ShowAsync(this.MessageText, this.CaptionText, this.mMessageButtonSelected.EnumKey, image, this.DefaultMessageButtonSelected.EnumKey, null, "", "", null, this.ShowCopyButton); this.Result = result.ToString(); }
private void ShowTestSampleMsgBox(string sampleID, Window sampleWindow) { MsgBoxResult result = MsgBoxResult.None; var msg = GetService <IContentDialogService>().MsgBox; switch (sampleID) { case "Sample 1": result = msg.Show("This options displays a message box with only message." + "\nThis is the message box with minimal options (just an OK button and no caption)."); break; case "Sample 2": result = msg.Show("This options displays a message box with both title and message.\nA default image and OK button are displayed.", "WPF MessageBox"); break; case "Sample 3": result = msg.Show("This options displays a message box with YES, NO, CANCEL option.", "WPF MessageBox", MsgBoxButtons.YesNoCancel, MsgBoxImage.Question); break; case "Sample 4": { Exception exp = this.CreateDemoException(); result = msg.Show(exp.Message, "Unexpected Error", exp.ToString(), MsgBoxButtons.OK, MsgBoxImage.Error, MsgBoxResult.NoDefaultButton, "http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=7799028", "http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=7799028", "Click the link to report this problem:"); } break; case "Sample 5": result = msg.Show("This options displays a message box with YES, NO buttons.", "WPF MessageBox", MsgBoxButtons.YesNo, MsgBoxImage.Question); break; case "Sample 6": result = msg.Show("This options displays a message box with Yes, No (No as default) options.", "WPF MessageBox", MsgBoxButtons.YesNo, MsgBoxImage.Question, MsgBoxResult.No); break; case "Sample 7": result = msg.Show("Are you sure? Click the hyperlink to review the get more details.", "WPF MessageBox with Hyperlink", MsgBoxButtons.YesNo, MsgBoxImage.Question, MsgBoxResult.Yes, "http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=7799028", "Code Project Articles by Dirkster99"); break; case "Sample 8": result = msg.Show("Are you sure? Click the hyperlink to review the get more details.", "WPF MessageBox with Custom Hyperlink Navigation", MsgBoxButtons.YesNo, MsgBoxImage.Question, MsgBoxResult.Yes, "http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=7799028", "Code Project Articles by Dirkster99", "Help Topic:", this.MyCustomHyperlinkNaviMethod); break; case "Sample 9": result = msg.Show("WPF MessageBox without Copy Button (OK and Cancel [default])", "Are you sure this right?", MsgBoxButtons.OKCancel, MsgBoxImage.Question, MsgBoxResult.Cancel, null, string.Empty, string.Empty, null, false); break; case "Sample 10": result = msg.Show("Are you sure? Click the hyperlink to review the get more details.", "WPF MessageBox without Default Button", MsgBoxButtons.YesNo, MsgBoxImage.Question, MsgBoxResult.NoDefaultButton, null, string.Empty, string.Empty, null, false); break; case "Sample 11": result = msg.Show("...display a messageBox with a close button and TakeNote icon.", "WPF MessageBox with a close button", MsgBoxButtons.Close, MsgBoxImage.Warning); break; case "Sample 12": { Exception exp = this.CreateDemoException(); result = msg.Show(exp, "Unexpected Error", MsgBoxButtons.OK, MsgBoxImage.Error, MsgBoxResult.NoDefaultButton, "http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=7799028", "http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=7799028", "Please click on the link to check if this is a known problem (and report it if not):", null, true); } break; case "Sample 13": { Exception exp = this.CreateDemoException(); result = msg.Show(exp, "Reading file 'x' was not succesful.", "Unexpected Error", MsgBoxButtons.OK, MsgBoxImage.Error, MsgBoxResult.NoDefaultButton, "http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=7799028", "http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=7799028", "Please click on the link to check if this is a known problem (and report it if not):", null, true); } break; case "Sample 14": { Exception exp = this.CreateDemoException(); result = msg.Show(sampleWindow, "...display a messageBox with an explicit reference to the owning window.", "MessageBox with a owner reference", MsgBoxButtons.OK, MsgBoxImage.Default_OffLight); } break; case "Sample 15": { result = msg.Show("...display a messageBox with a default image.", "MessageBox with default image", MsgBoxButtons.YesNoCancel, MsgBoxResult.No, "http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=7799028", "http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=7799028", "Please click on the link to check if this is a known problem (and report it if not):", null, true); } break; // Display a message box that will not close via // Esc, F4, or Window Close (x) button. case "Sample 16": { result = msg.Show("...Display a message box that will not close via Esc, F4, or Window Close (x) button.", "MessageBox with default image", MsgBoxButtons.YesNoCancel, MsgBoxResult.None, false, MsgBoxResult.No, "http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=7799028", "http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=7799028", "Please click on the link to check if this is a known problem (and report it if not):", null, true); } break; // Display a message box that WILL CLOSE // via Esc, F4, or Window Close (x) button leaving with a No result. case "Sample 17": { result = msg.Show("...Display a message box that will close via Esc, F4, or Window Close (x) butto resulting in a No Answer", "MessageBox with default image", MsgBoxButtons.YesNoCancel, MsgBoxResult.No, true, MsgBoxResult.No, "http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=7799028", "http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=7799028", "Please click on the link to check if this is a known problem (and report it if not):", null, true); } break; } this.Result = result.ToString(); }