“The WPF mindset”: WPF elements are styled by the WPF engine walking the visual tree up, not down (like the CSS engine does) (courtesy of SO user Sebastian Edelmeier).

To have CSS-like styling, see this: http://www.codeproject.com/Articles/36499/Using-CSS-Selectors-for-Styling-in-WPF

And now, the current rules:

  • Local property set has higher priority
  • Within a style, triggers take precedence
  • Local styles have higher priority than global styles

To merge multiple styles into one, define a markup extension.

For in-depth information, refer to https://msdn.microsoft.com/en-us/library/ms743230.aspx

Another good article: https://wpf.2000things.com/2010/11/22/133-where-a-dependency-property-gets-its-value/

To properly define styles at app root level and then add slight variations to them, use the BasedOn attribute.

 

 

Advertisements