views:

299

answers:

2

How can you access WPF's built-in styles/templates?

For example I'm trying to move the NavigationWindow's chrome to the bottom of the window. I've seen Microsoft's NavigationWindow template example but it is quite verbose and doesn't reuse the default navigation chrome.

I've also tried looking at the tree inside Snoop. All the chrome is contained inside a grid element called "NavChrome" but I can find any reference to it. There doesn't seem to be any "PART_xyz" that matches it either.

For the CTP some people mention using "PFThemeNavigationWindowNavigationButtonForwardButtonStyle", etc, for the button styles, however this doesn't seem to work anymore.

So, is it possible to access these built-in styles? It would be nice to reuse them in other places too!

Thanks!


Edit: saldoukhov's answer is very helpful but is there a way to do this without a need to copy all that XAML? It just doesn't seem like a very DRY approach to me.

+4  A: 

I usually do it in Expression Blend. Select the control->right-click->Edit Control Parts (Template)->Edit a Copy...

Then it depends on what you want to do. If you're lucky and the template you're editing contains reference to key'ed resources changing which you can get the desired effect, then you can just create your own resources with this key and they would "override" the ones in the template, in this case you do not need to carry around the full template. But more often, you need to change a few things around the template, so you just extract it into your own resources and start to carry around.

Sergey Aldoukhov
+2  A: 

Not an answer to your question, but a little hint: In addition to saldoukhov's answer, you can also use XamlPadX (http://blogs.msdn.com/llobo) to get access to the built-in styles, if you don't have Expression Blend.

Christian Hubmann