PowerShell GUI: Use the Mahapps Badged control


In this post, I will show you a nice control to use using PowerShell and Mahapps. We'll see how to manage and use it.
If you often read my posts, you may know that I'm a big fan of Mahapps. It's just, for me an awesome way to give some pretty cool design to GUI. 
Some weeks ago a colleague, Kevin Rahetilahy (aka Dev4sys), has shown me a new Mahapps control that I missed. 
I was what ? I like it, I have to test it and share how to use it.

What is this ?

This control can be compared to the Windows 10 notifications below:
See below what you do with this control.


Badge color

You can first apply the badge to a simple button.
You can apply the color you want to the badge control. In the below example I show some colors that can be pretty to use.
You can also apply a fix number to the badge or use it to display a warning.
In the below example, I created two buttons
System error: it shows the number of system error in the event log during the last day
Application error: it shows the number of application error in the event log during the last day
This control can be very useful to use to highlight some options, or missed parameters. 


Badge with icon

You can also apply, the badge control to a button displayed by an icon.
See below how it can looks like.

Badge location

The third tabitem in my example shows the different available locations on your button.


How to use it ?

Badge in XAML 

How to add a badge to a simple button ?

See below, the code used to display a badge on a simple button.

How to add a badge on a icon button ? 

See below, the code used to display a badge on an icon button

How to add a badge to a tabcontrol ?

See below, the code used to display a badge on a TabControl

How to modify the location of a badge ?

See below the attribute used to modify to the badge location.

How to modify the color of a badge ?

See below the attribute used to modify the badge color


Badge in PS1

See below the code used to modify the value of the badge.

See below the code used to modify the color of the badge



When to use it ?

This control can be very useful. My colleague Kevin used it, in his great tool driver manager,link here.
This tool allows you to see if there are some missing drivers on your computer, of there is an issue with some of them.
It's composed of 3 Tabs, and a badge indicates you directly the number of missing drivers, see below.


You can also imagine a button that will show you the number of event log error during a specific period. You can find an example in my post.

Previously, I shared a tool that allows you to monitor your MDT Deployment. This way you can see if there are deployments running on computers, completed deployment or also deployment failure. 
So, why not using this control to resume quickly number of each part ?

There are many possibilities to use with this control, just use your imagination.



How to get my sample ?


Share this

Related Posts

Previous
Next Post »