Tuesday, March 24, 2009

WPF: Generalizing using generic.xaml

In my previous post, I went on (and on) about a mechanism for loading generic styles and data templates using a Uri load component scheme. This would load your styles and apply them to the control or window that does the loading.

Since then, I've discovered the somewhat magical and better solution to all this, which is to define a file called \Themes\Generic.xaml in your project root. This apparently tells WPF to tap into its uber styling code and plug in your styles defined here.
I had to dig deeper here, because my templated code was working for my main component, but as soon as I added it to the definition of a floating frame outside of the control (which is a third-party component that I don't have control of) it failed to read the template. Adding the Data template definition to \Themes\Generic.xaml did the trick.

1 comments:

Anonymous,  May 27, 2010 at 5:54 AM  

I had the same problem with the floating frame part ;) Thanks for the last part, really helped a lot!!!

Post a Comment

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Back to TOP