1

I was trying to force the WPF application to use the classic windows theme by using the following statement

<ResourceDictionary Source="/PresentationFramework.Classic;V3.0.0.0;31bf3856ad364e35;component/themes/classic.xaml" />

This used to work fine with .net 3.5. But once i switched to .net 4.0 this doesn't seem to work. Can anyone tell me how i can get this working in 4.0 framework. I tried replacing the version numbers and the public key tokens with the PresentationFramework.Classic.dll's values but my efforts turned futile... Can anyone suggest me something?

nwalke
  • 3,170
  • 6
  • 35
  • 60
Anee
  • 463
  • 9
  • 26
  • Yeah i can see that. I replaced it with the version number of the dll in 4.0 @BoltClock – Anee Mar 16 '11 at 09:02

1 Answers1

0

You don't need to set the version number. You can simply use it like

For Classic:

<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="/PresentationFramework.Classic;component/themes/classic.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>
<Grid>
    <Button Width="120" Height="24"/>
</Grid>

For Royale:

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/PresentationFramework.Royale;component/themes/royale.normalcolor.xaml" />
    </ResourceDictionary.MergedDictionaries>

The "Copy Local" property must also be set to true on the assembly after it's referenced. By default I had only Aero2, I replaced it with Classic, but it didn't work until I set copy local to true.

Shahin Dohan
  • 6,149
  • 3
  • 41
  • 58
Prince Ashitaka
  • 8,623
  • 12
  • 48
  • 71
  • @Anee do you receive any exception? – Prince Ashitaka Mar 16 '11 at 10:19
  • I've tried the above code I suggested in both 3.5 and 4.0 framework. It is working perfectly. Do you have PresentationFramework.Classic.dll reference added to your application? – Prince Ashitaka Mar 16 '11 at 10:24
  • Well, i've included the reference to PresentationFramework.Classic.dll in the project. Still i see no difference. This thing works in .net framework 3.5 @ Prince Ashitaka – Anee Mar 16 '11 at 14:10
  • Doing it this way and setting copy local is probably not correct. You shouldn't be distributing parts of the framework locally with your application, and you also should not need to: https://stackoverflow.com/a/8185946/3195477 – StayOnTarget Jan 13 '22 at 21:20