Do these themes work with WPF?

Nov 6, 2009 at 3:43 PM

I tried a couple of the themes, such as the UX red/green and they wouldn't work in my WPF app.  Are the SL themes not compatible with WPF? If not, then I would suggest changing the site a bit because it leads people to believe they do indeed work.

If they do work, what do I need to do? Most of the problems were from the Visual State Manager which doesn't seem to exist in WPF.

Thanks

Nov 6, 2009 at 4:29 PM

Visual State Manager is included with the WPF Toolkit (http://www.codeplex.com/wpf) you will need to reference this assembly for the skins to work. SL themes in general are not compatible with WPF, these particular themes though have been ported by rudi.

Jan 22, 2010 at 8:21 AM

I've been trying to get the basic released themes to work in a WPF Project.

Downloaded the WPFToolkit and Silverlight 3 SDK.

Referencing the WPFToolkit.dll works fine with my project, but when I try to reference System.Windows.Controls.Theming.Toolkit.dll

it keeps telling me I have an a Assembly mismatch. The .xaml Theme files reference that *.dll and examples have shown to include it.

Where am I going wrong on this?

I'd appreciate any advice / help.

 

Thanks in advance

Jan 22, 2010 at 9:31 AM

Unless your really want to go down the dll root I would suggest using the raw xaml files instead. Remove reference to System.Windows.Controls.Theming.Toolkit.dll

and in your constructor or window.load handling add the following.

//New resource dictionary.
ResourceDictionary skin = new ResourceDictionary();

//Set new source.
skin.Source = new Uri(@"C:\myskin.xaml", UriKind.Absolute);

//Merge.
App.Current.Resources.MergedDictionaries.Add(skin);

Where "C:\myskin.xaml is the absolute path to the theme you wish to apply. Using the raw xaml as aposed to the dll means you can customize the styles yourself. Also if you move the above code to a method you can change the theme during runtime.

Jan 22, 2010 at 9:54 AM

First of all, thanks for the speedy reply Nobster.

So I started from scratch:

New WPF App; referenced WPFToolKit, added your code to constructor window for testing; added fresh "System.Windows.Controls.Theming.ExpressionDark.xaml" to Project.

and.....nothing :) no build for me

Is my assumption correct that I have to alter the ResourceDir of the "Theme".xaml ?

I altered the line xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" to

the WPFToolKit assembly but that only led to another row of errors...

What am I missing? :) The WPF Theme section described porting these themes as totally simple :(

Jan 22, 2010 at 10:20 AM


In the line skin.Source = new Uri(@"C:\myskin.xaml", UriKind.Absolute); change C:\myskin.xaml to wherever you have the xaml file on your harddisk.

So if your expressiondark.xaml file was called expressiondark.xaml and was sitting on the root you would rename C:\myskin.xaml to C:\expressiondark.xaml.

You don't need to change anything in the xaml itself and nothing other then WpfToolkit  needs to be added to the project although I'm sure you could add the xaml file as a resource but then you'll need different syntax to use it.

Above when you say  "nothing :) no build for me" do you mean your getting an error?

Jan 22, 2010 at 10:47 AM

To clear things up I added and altered your code to point to my .xaml sorry should have written that.

here the constructor code:

public partial class Window1 : Window
    {
        public Window1()
        {
            //New resource dictionary.
            ResourceDictionary skin = new ResourceDictionary();

            //Set new source.
            skin.Source = new Uri(@"D:\VS2008_Projects\WpfApplication1\WpfApplication1\System.Windows.Controls.Theming.ExpressionDark.xaml", UriKind.Absolute);

            //Merge.
            App.Current.Resources.MergedDictionaries.Add(skin);


            InitializeComponent();
        }
    }
and here whats in the ResourceDirectory at the top of the ExpressionDark.xaml:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:system="clr-namespace:System;assembly=mscorlib" 
                    xmlns:inputToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit"
                    xmlns:vsm="clr-namespace:System.Windows;assembly=WPFToolkit"
                    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
                    xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
                    xmlns:input="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input"
                    xmlns:controlsPrimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls"
                    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
                    xmlns:dataPrimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
                    xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" 
                    xmlns:visualizationToolkit="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
                    xmlns:chartingPrimitivesToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting.Primitives;assembly=System.Windows.Controls.DataVisualization.Toolkit"
                    xmlns:dataForm="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
                    xmlns:inputPrimitivesToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input"
                    xmlns:inputToolkitPrimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Input.Toolkit"
                    xmlns:layoutPrimitivesToolkit="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Layout.Toolkit"
                    xmlns:layoutToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
                    xmlns:theming="clr-namespace:System.Windows.Controls.Theming;assembly=System.Windows.Controls.Theming.Toolkit"
                    xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"  >

I have referenced the WPFToolkit and added the file to my project. The xaml file is found through your code. But I get errors and it won't build:
Error	1	The property 'UseLayoutRounding' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'. Line 84 Position 60.	D:\VS2008_Projects\WpfApplication1\WpfApplication1\System.Windows.Controls.Theming.ExpressionDark.xaml	84	60	WpfApplication1
And that's just one of many, I am referencing something wrong? ...
Jan 22, 2010 at 10:55 AM

I had made one change to the DarkExpression.xaml

xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"

was the original state of the entry. If I leave it at that I can an error stating that

Error	1	The tag 'VisualStateManager.VisualStateGroups' does not exist in XML namespace 'clr-namespace:System.Windows;assembly=System.Windows'. Line 33 Position 14.	D:\VS2008_Projects\WpfApplication1\WpfApplication1\System.Windows.Controls.Theming.ExpressionDark.xaml	33	14	WpfApplication1

 

so yeah.......I 'm kinda stumped

Jan 22, 2010 at 11:06 AM
Edited Jan 22, 2010 at 11:12 AM

Ok not sure why all those assembly references are in there. Where did you get this version of the theme?

I re-downloaded the one from microsoft to check and it looks like this

<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="d"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008">

I would re-download expression dark from here, http://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=14962

or try my modified theme which supports calendar and datagrid as well http://www.mediafire.com/file/0iugmzygmmz/ExpressionDark.xaml.

EDIT: I would also call  InitializeComponent(); before running any other code but I don't think it matters when just loading a theme.

Jan 22, 2010 at 11:26 AM

It compiles! :D And the button looks expressionistically Dark :D

Ok the breakdown:

It was indeed the wrong xaml file. And guess I found out my error:

http://wpf.codeplex.com/wikipage?title=WPF%20Themes&referringTitle=Home

The describing sentence:

An updated collection of seven themes replaces the original nine WPF Themes. 
Some of the issues with the original themes have been addressed in this update. 
Download the WPF Themes in the WPF Futures release. This collection of themes can also be found in the Silverlight Toolkit. 
Led me to believe I could take the design files out of my Silverlight SDK that I had already downloaded.
But I guess those are specifically for Silverlight(?).
Thank you very very much for the troubleshooting help Nobster.
Jan 22, 2010 at 11:34 AM

No worries, glad you got it sorted