0

I specifically want to be able to leverage some of the system theme templates and definitions (colours and brushes) for my own custom control. I "think" I'm supposed to use the element in my generic.xaml's root element.

Considering I'm supposed to use some kind of path for the "Source" attribute, what would the path look like for "Aero2"?

Is this even accepted use? Am I allowed to use system themes?

Edit: Since this is a common theme of questions, here are a few other references. How can I set a WPF control's color to a system color programmatically, so that it updates on color scheme changes? Get Aero Window Colour

My goal is to use colours as defined in other ResourceDictionaries -- since they don't seem to match the "SystemColors" namespace.

Community
  • 1
  • 1
chrisp
  • 2,181
  • 4
  • 27
  • 35

1 Answers1

0

See here.

Basically you need this:

<ResourceDictionary
    Source="/PresentationFramework.Aero, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL;component/themes/aero.normalcolor.xaml" />
Community
  • 1
  • 1
N_A
  • 19,799
  • 4
  • 52
  • 98
  • Thanks for the link to the other SO q&a. I have the ResourceDictionary working now (the compiler finds it), but when I try and reference to a brush in that other ResourceDictionary (i.e.:{StaticResource ResourceKey=TextBox.Static.Border}), I get a "could not be resolved" error. – chrisp Mar 13 '13 at 16:03
  • Does this help? http://stackoverflow.com/questions/6710265/setting-wpf-window-background-to-resource-dictionary-brush-user-setting – N_A Mar 13 '13 at 16:10
  • It looks like it might be an option, but is it really required if I just want to be able to use a system defined colour? Not a gripe, as I'm new to wpf, but I really just want to be able to leverage already defined part styles for a custom control. – chrisp Mar 13 '13 at 16:13
  • WPF themes are just resource dictionaries. See here for more information: http://msdn.microsoft.com/en-us/library/ms745683.aspx#styling_themes – N_A Mar 13 '13 at 16:16
  • Which is exactly what I've understood. So I just want to be able to use some of the definitions for my own control. I've also found that just adding a reference to the ResourceDictionary -> "" is throwing a System.IO.FileNotFoundException when trying to launch my sample. (I have a reference to the assembly in my project.) -- EDIT: I also had to add a reference to the assembly in the main project, not just the custom control library. – chrisp Mar 13 '13 at 16:21
  • This is where I'm currently "stuck": {"Cannot find resource named 'TextBox.MouseOver.Border'. Resource names are case sensitive."} – chrisp Mar 13 '13 at 16:24
  • If you don't mind pulling the values into your own resource dictionary, you can grab the actual .xaml themes: http://stackoverflow.com/questions/4158678/where-can-i-download-microsofts-standard-wpf-themes-from – N_A Mar 13 '13 at 18:34
  • That's actually something that I originally considered (once I had discovered how to get the original source). I guess a final question of sorts, am I the only one that finds it so odd that simply "hey let me use the Aero2 theme textbox border tracking/mouseover colour" is so convoluted? (The value is easy enough to get with a colour picker or some interface spy : #FF7EB4EA) I thought there'd be a more extensible method. – chrisp Mar 13 '13 at 19:28
  • My understand is that the way you're trying to use it isn't intended. See here: http://blogs.msdn.com/b/wpfsdk/archive/2007/07/31/using-themes-with-custom-controls.aspx – N_A Mar 13 '13 at 19:38