WPF Theme Selector with WPF Toolkit/WPF Futures

by Brad Hunt May 11, 2009
The WPF Theme Selector Add-In for Visual Studio is a handy tool for quickly adding a reference to a custom WPF theme file.  But what if you want to use it with a 3rd party themes project such as those found in WPF Futures?  In this blog, I will be looking at what it takes to do just that, and the good news is that the process is actually pretty simple. The first thing to remember is that the WPF Theme Selector Add-In makes no attempt to parse xaml files and find dependencies.  Therefore, if the theme you want to apply depends on some other library, such as the WPFToolkit (as WPF Futures does), then it is your responsibility to make sure that library is installed and referenced appropriately. So let's look at applying a theme from the WPF Themes collection that comes with WPF Futures.  As I have mentioned, WPF Futures requires the WPFToolkit to be installed on the machine and referenced in your project.  If you have not already installed the WPF Toolkit, you can download the installer for free here: http://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=25047 Once you have run the installer for the toolkit, you will need to add a reference to it in your WPF project.  Right-click on the "References" folder inside your project and click Add Reference. When the Add Reference window pops up, click the browse tab and browse to the location where you installed the toolkit.  By default, the dll will be located here: C:\Program Files\WPF Toolkit\v3.5.40320.1 Go ahead and add references to all 3 dlls in that folder.  WPFToolkit.dll will allow you to see the theme applied at run-time, while the other two offer design-time support. Now that the toolkit is installed and referenced, let's get the WPF Themes collection that is part of the WPF Futures project.  You can download the themes by going to this URL and clicking the "WPF Themes" link: http://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=14962 Download the zip file and extract the contents to a location that is easy to remember.  Iside the Themes folder is a folder called "XAML" which contains all the xaml theme files that are included with WPF Futures.  Drag the XAML file into your WPF project in Visual Studio. Now you are ready to apply a theme with the WPF Theme Selector.  Click Tools > WPF Theme Selector.  Double-click the XAML folder, and choose the theme you want to apply to your project.  And that's it!  You can now run your project and see the theme applied.   Here are a couple more tips: If you are not seeing the theme applied in design view, try opening App.xaml (or Application.xaml in VB.NET) and removing leading slashes from the Source Property of the ResourceDictionary tag.  It seems that while the runtime is able to resolve the path with leading slashmarks, the design tools are unable to resolve it. If you are using the WPF Themes that are part of WPF Futures, you may notice that the background does not show up right away.  You can fix this by applying the WindowBackgroundBrush (defined inside the theme file) to the Background property of the Window tag and/or applying the ControlBackgroundBrush to the Background property of the Grid tag like this: <Window Background="{DynamicResource WindowBackgroundBrush}" ...<Grid Background="{DynamicResource ControlBackgroundBrush}">

WPF Theme Selector Available

by Brad Hunt May 5, 2009
Smooth Fusion has developed a simple Visual Studio 2008 add-in that allows WPF developers to easily apply a theme to their WPF project. After installing the add-in, you will be able to navigate to a theme file and have the theme applied to your C# or VB.NET project. Have a look and let us know if it is helpful. Documentation and source code can be found on CodePlex: http://wpfthemeselector.codeplex.com  

Tags:

Search Blog

About Smooth Fusion

We specialize in helping marketers with the planning and implementation of digital campaigns and ongoing programs. We are a trusted partner to marketing agencies and corporate marketers worldwide, delivering our unique blend (or fusion) of technical expertise and understanding of the needs of marketers.

Our team is made up of consultants, project managers, software engineers, developers, designers, and quality assurance specialists. And what we all have in common is experience using technology to empower marketers. Unlike most technical groups, Smooth Fusion exists to specifically assist marketers.

We do our work from our home base in West Texas with our fulltime in-house staff and a small group of select freelancers. Learn more about Smooth Fusion.