tags:

views:

125

answers:

1

Hi all,
simple question regarding property value inheritance in UserControls.
If i create a UserControl, it has some standard properties like Background, BorderBrush and BorderThickness.
Within that UserControl i have a border. I want to know, if i dont specify any set value or binding for the property BorderBrush of that border, will it automatically inherit the value of BorderBrush from the parent control?

Thanks!

+3  A: 

It depends. Properties in WPF are usually implemented using Dependency Properties. These properties can be defined to inherit their value from the ancenstor. You have to look in the documentation for each property, if it is inherited or not.

The BorderBrush, BorderThickness and Background properties are not inherited (wouldn't make sense most of the time).

An example for an inherited property is the DataContext property (since it makes sense for child elements to have the same data context as their parent)

See also MSDN info on Dependency Properties for further information.

MartinStettner
Thanks :) was struggling with how much of a control i should databind to the parent and wondering if it was overkill. Thanks for your reply
TerrorAustralis