in

WPF Theme Selector

  • WPF Theme Selector with WPF Toolkit/WPF Futures


    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

    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

     

    Posted May 05 2009, 10:53 AM by bhunt with no comments
    Filed under:
Powered by Community Server (Commercial Edition), by Telligent Systems