locked
Where is the resource in the custom control themes? RRS feed

  • Question

  • When we add a custom control via VS, a themes fold will be created by default, and a generic.xaml file will be added to it, then we can define style for the custom control. However, I wonder where is the resource in the generic.xaml will be in the runtime. I have search the custom control's resources dictionary, and the application's resources dictionary, but didn't find any. Do someone know?

    The curious thing is that if I define a style with a normal key(string type), then I cannot use this style in another assembly via DynamicResource, however, I and use ComponentResourceKey to accomplish it. Why?

    Thanks for anyone who will give me a reply on this. :)


    Diwore
    Monday, April 26, 2010 5:30 PM

Answers

  • Levin, use the targettype in resource, so all in your project that use the custom control the style will be applied.
    • Proposed as answer by Thiago MDTech Monday, April 26, 2010 6:57 PM
    • Marked as answer by Linda Liu Monday, May 3, 2010 1:06 AM
    Monday, April 26, 2010 6:57 PM

All replies

  • I can't say that I have ever tried to hunt down the exact location of generic.xaml in an assembly, but I do know that the assembly level attribute ThemeInfoAttribute will tell you the general location of the ResourceDictionary from generic.xaml.  This attribute is described on in the following msdn article http://msdn.microsoft.com/en-us/library/system.windows.themeinfoattribute.aspx and should let you know whether or not the generic.xaml file is located in the source assembly or not.  Most likely the generic.xaml file is located in the source assembly and you will just have to poke around a little bit more in order to find it.
    Monday, April 26, 2010 6:56 PM
  • Levin, use the targettype in resource, so all in your project that use the custom control the style will be applied.
    • Proposed as answer by Thiago MDTech Monday, April 26, 2010 6:57 PM
    • Marked as answer by Linda Liu Monday, May 3, 2010 1:06 AM
    Monday, April 26, 2010 6:57 PM
  • Thanks Nine, I have found the location : System.Windows.SystemResources. It's a static class. It seems WPF has a special implementation for Custom Control's Themes, what's more, the DynamicResource won't look for it location.
    Diwore
    Tuesday, April 27, 2010 8:04 AM
  • Yes, only use targettype is useful for it, however, this won't meet my requirement. Anyway, I have found the location, Thanks for your reply.


    Diwore
    Tuesday, April 27, 2010 8:06 AM