Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Powershell WPF Themes guide step by step

I have wrote many Powershell GUI scripts but never thought using any themes on WPF GUI forms, As it is not required for internal organization use and it can be used without any different skin, but as I started sharing my GUI scripts on, adding GUI to it makes more professional and attractive. I am here adding basic themes which I am downloading for one time using Visual Studio. Open Tools menu and expand NuGet Package Manager then select Package Manager Console.

On the Package Manager Console type command Install-Package wpf.themes. This start downloading themes packages from nuGet gallary Location of download is as shown in the screenshot it might be different for you and can be found in VS wpf project folder Wpf.Themes.1.1.0\content\Themes. It has themes xaml files. I have copied this themes folder as it is portable and I copied it some other place so In my powershell script it can take the path from one central location.

I have all my ps1 files and themes folders are kept under C:\Temp folder location. Mentioned the theme xaml filename with folder path location as below on the 4th and 5th top line of the script. This creates the path name of the xaml file.

$ScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
$ThemeFile = Join-Path -Path $ScriptPath -ChildPath Themes\BureauBlack.xaml

And (yellow highlighted code in the screenshot) copy code after Title and before grid control as it is. 


After launching the script, theme shows good but with issue font color for checkbox and radiobutton are not showing correct and color is white as seen in the first screenshot.. 

To resolve this issue I am adding few more lines to XAML code and in one go changing font color for all CheckBoxes and RadioButtons to black, Here you can change all controls color with this small code, I have mentioned 2 style target types, it need to insert between closed MergeDictionaries and closed ResourceDictionary.


Below are all the themes tested they are good and working fine. Adding form background color to the form makes it more good looking, Background="ColorName" property can be added to title object.

Complete code can be found here, It is also available on In next articles I will be covering some more common themes to be used.

Useful Articles
Part 1: Create WPF XAML Powershell Gui form with Visual studio
Part 2: Powershell and WPF: Build GUI applications tutorial
Part 3: Create shorter Microsoft Powershell WPF automated clean script
Powershell PoshGUI: Convert user to SID and vice versa using
Microsoft Powershell GUI: Change Internet Options connections Lan settings proxy server grayed out

This post first appeared on Tales From Real IT System Administrators World And Non-production Environment, please read the originial post: here

Share the post

Powershell WPF Themes guide step by step


Subscribe to Tales From Real It System Administrators World And Non-production Environment

Get updates delivered right to your inbox!

Thank you for your subscription