Jerry Nixon @Work: Inheritable, compound styles in WPF4 with the BasedOn attribute

Jerry Nixon on Windows

Friday, July 2, 2010

Inheritable, compound styles in WPF4 with the BasedOn attribute

Maybe you have a base style you would like to enhance for a single or single set of controls. Using the BasedOn property, your style can inherit the settings of the “base” and expand it or override it where you want. It’s that easy.

According to MSDN, each style only supports one BasedOn value. But that does not mean you cannot have a long lineage of inherited styles. 1 –> 2 –> 3 –> 4 and so on. This really makes it nice when you have a large application.

image

Get the code here.