views:

32

answers:

1

In WPF and Silverilght, what are the rules for deciding if you inherit properties from the visual, declarative, or logical parent?

+2  A: 

I must assume you meant property inheritance, because otherwise the question makes no sense: You don't use class inheritance from your visual/logical parent - you simply have a reference to that parent.

Inherited properties are inherited in the following priority order:

  1. From the logical parent, if any, otherwise...
  2. From the visual parent, if any, otherwise...
  3. From the a control-specific inheritance context (such as a Popup window from a Popup), if any. This is likely to be the object corresponding to the containing tag in XAML (which I assume is what you mean by the "declarative parent.")

If none of these types of parents exist or have the value being inherited, the value is set using styles or defaults.

Ray Burns