当我在类层次结构之外的类中定义附加的依赖项属性并将所有者设置为公共父类时,我收到此错误。
WindowBase类中的附加依赖项属性(类层次结构=>生成错误之外):
public static readonly DependencyProperty AreaColorProperty =
DependencyProperty.RegisterAttached("AreaColor", typeof(AreaColor), typeof(Window));
失败的TemplateBinding
{TemplateBinding local:WindowBase.AreaColor}
如果我在类heirarchy中的类中定义附加的依赖属性并将所有者设置为此类,那么我没有得到任何错误,为什么会这样?
WindowBase中的附加依赖属性(在类层次结构中=>没有错误):
public static readonly DependencyProperty AreaColorProperty =
DependencyProperty.RegisterAttached("AreaColor", typeof(AreaColor), typeof(WindowBase));
最诚挚的问候, 的Jesper
答案 0 :(得分:2)
我通过切换到相对源绑定解决了这个问题:
{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=(Window.CaseAreaColor)}