型「System.Windows.TemplateBindingExtension」の対象に「[attrの]」属性に値を変換できません。

StackOverflow https://stackoverflow.com/questions/2608082

質問

私はクラス階層外のクラスで私の添付依存プロパティを定義し、共通の親クラスに所有者を設定すると、私はこのエラーを取得します。

WindowBaseクラスの添付依存性(外部クラス階層=>生成されたエラー):

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

TemplateBindingのそれが失敗した。

{TemplateBinding local:WindowBase.AreaColor}

私が代わりにクラス階層構造内のクラスで添付依存関係プロパティを定義し、このクラスに所有者を設定すると、私はすべてのエラーを得ることはありません、なぜこれが?

WindowBaseで結合依存性(クラス階層内=>エラーなし)

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

よろしく、 ジェスパー

役に立ちましたか?

解決

I結合相対ソースに切り替えることで問題を解決します:

{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=(Window.CaseAreaColor)}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top