Cannot convert value in attribute '[attr]' to an object of type 'System.Windows.TemplateBindingExtension'

I get this error when I define my related dependency properties in a class outside the class hierarchy and set the owner to a common parent class.

Bound dependency property in the WindowBase class (external class hierarchy => generated error):

public static readonly DependencyProperty AreaColorProperty =
DependencyProperty.RegisterAttached("AreaColor", typeof(AreaColor), typeof(Window));

Template Error

{TemplateBinding local:WindowBase.AreaColor}

If instead I define an attached dependency property in a class inside the class hierarchy and set it for this class, then I get no errors, why is this?

A related dependency property in WindowBase (inside the class hierarchy => no errors):

public static readonly DependencyProperty AreaColorProperty =
DependencyProperty.RegisterAttached("AreaColor", typeof(AreaColor), typeof(WindowBase));

Regards, Jesper

+3
1

, :

{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=(Window.CaseAreaColor)}
+2

Source: https://habr.com/ru/post/1740464/


All Articles