views:

28

answers:

1

Normally wpf objects inherits their parent's data context, so if you set a binding and theres no data context set, the binding engine it will automatically look for it in the parents. How can I make a custom class(that is not an UI element) to produce the same behavior when set as the child of another element?

+1  A: 

Make it a subclass of Freezable

Thomas Levesque
Freezable doesn't include a DataContext... Not sure how this is supposed to help here. DataContext is a defined on FrameworkElement.
Reed Copsey
Can't I implement this behavior myself? I don't want to subclass from freezable just to do that...
Thiado de Arruda
I don't think you can... you must at least inherit DependencyObject, since only dependency properties are bindable
Thomas Levesque
@Reed : it doesn't need a DataContext. The binding will use on the parent's DataContext
Thomas Levesque