
New-WPFMessageBox -ButtonType Abort-Retry-Ignore $Params = "The file 'Important Document.docx' could not be deleted." Simply select an option using the ButtonType parameter. The default button is the OK button, but you can also use other buttons or button combinations such as Yes/No, Retry/Cancel, Abort/Retry/Ignore etc. You can change the button color using ButtonTextForeground: New-WPFMessageBox ContentBackground to change the main content background: When using several parameters, it can be easier to ‘splat’ them like so: The Content… parameters allow you to change the main content section, and the Title… parameters allow you to change the title. The FontFamily parameter is also dynamic and allows you to select from fonts available in. You can change the fonts, font weights and font sizes, as well as the background and foreground colors to create some nice combinations. New-WPFMessageBox -Content "I'm a WPF Object!" -Title "Custom Message Box" -TitleBackground CornflowerBlue This parameter is a dynamic parameter and will allow you to select from the list of available colors in the. Use the TitleBackground parameter to change the color. The title bar is a color block, so it can be used to create a nice contrast with the main content, for example. New-WPFMessageBox -Content "I'm a WPF Object!" -Title "Custom Message Box" To add a header, simply use the Title parameter: The Content parameter is the only mandatory parameter, and can take either a simple text string or your own custom WPF content (which we’ll look at later). New-WPFMessageBox -Content "I'm a WPF Object!" To create a simple message box, all you need to do is pass a string to the Content parameter: Let’s have a look at some ways we can use this function. The message box has a basic default design, but if you’re the creative type then you can customize away until you get an appearance you like. My goal was to create a good-looking, fully-functional message box window that is highly customizable in the WPF format, and can even be used as a window host to display custom WPF content. So I decided to create my own customizable message box in WPF as a PowerShell function that can be used in my scripts and UI tools.Įnter New-WPFMessageBox.

In this age of modern design languages like Metro and Material Design however, this message box is starting to look a little dated. I’ve used it in my PowerShell scripts as well as my UI tools and even in my ConfigMgr task sequences for providing feedback to the end user.īoth WinForms and WPF also have a message box but they have similar style and functionality to the VBScript version. The humble VBScript message box has been around for a while now and is still a useful way of providing a simple pop-up notification in Windows.

TRUE DIALOG BULK SMS SENDER UPDATE
Update | Changed the way the output from a button click is handled, saving it to a variable instead.
