Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF: message box with checkbox added

Tags:

c#

.net

vb.net

wpf

In WPF I am looking for a "do not show again" checkbox on my messagebox popup.

Does anyone know where I can get such a control or maybe how to copy the style of the regular WPF messagebox so I can create my own?

Thanks

like image 525
Bob Avatar asked Nov 05 '22 05:11

Bob


1 Answers

Take a look at the Dialog Boxes Overview. The overview covers Message Boxes, Common Dialog Boxes, and Custom Dialog Boxes. In your case you'll want to create a simple Custom Dialog Box that includes a message, a checkbox, and however many buttons you need.

Basically you need to define a new code-behind file that includes your TextBlock, CheckBox, and Buttons in a panel object, and you need to extend Window. In your code-behind file you implement any necessary logic to implement the user's choice, and you return this result to the object containing the custom dialog box.

Make sure to pay special attention to this line of code when creating your custom dialog box:

// Open the dialog box modally 
messageBox.ShowDialog();

The call to ShowDialog() will ensure that the user must take action against your dialog box before moving on to other parts of your application.

like image 189
McStretch Avatar answered Nov 10 '22 19:11

McStretch