Alternate Themes [problem]

Oct 1, 2010 at 6:44 PM
Edited Oct 1, 2010 at 6:48 PM

I was trying to get the Generic.xaml theme to work with the notion of creating a new theme based on the approach.  I note that both Luna.xaml and Aero.xml have the following in their header:

<ResourceDictionary  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:local="clr-namespace:WPF.MDI;assembly=WPF.MDI">

Note particularly the last namespace declaration.   Later a style is defined for  <Style TargetType="{x:Type local:MdiChild}">.

Now the namespace in Generic.xaml header is for unknown reasons defined as:

<ResourceDictionary  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:local="clr-namespace:WPF.MDI">

with no assembly declaration.   This, allows the xaml to compile, however, loading the generic theme as:

       Application.Current.Resources.MergedDictionaries.Add(
currentResourceDictionary = (ResourceDictionary)XamlReader.Load(Application.GetResourceStream(new Uri(@"WPF.MDI;component/Themes/Generic.xaml", UriKind.Relative)).Stream));

 fails, as complains that cannot find MdiChild at runtime (due to the missing assembly specification in the namespace).    Now if one adds in the assembly into the Generic.xaml to:

<ResourceDictionary  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:local="clr-namespace:WPF.MDI;assembly=WPF.MDI">

Generic.xaml fails to compile, complaining about unknown type MdiChild.   I note that the code to dynamically load the Generic style was missing in the switch within ThemeValueChanged().   I'm wondering whether the author or others have been able to create new themes and whether have encountered this problem.

In fact, one can copy Aero.xaml over Generic.xaml and get the following error in compilation of Generic.xaml (but not get any errors for Aero.xaml and Luna.xaml):

Error 1 The type reference cannot find a public type named 'MdiChild'. Line 314 Position 49. C:\Dev\...\WPF.MDI\Themes\Generic.xaml 314 49 WPF.MDI

Can someone clue me in as to what needs to be done to make this work properly?

thanks