私は次の構造を持っています:
public static class Constants {
public static class Foo {
public static string Bar {
get {
//Constants.Foo.Bar == "FooBar"
return "FooBar";
}
}
}
}
これをユーザーコントロールのボタンにバインドしたい。
<Button Content="{Binding Source={x:Static ns:Constants.Foo.Bar}}" />
(ns は、"定数" が定義されているアセンブリと名前空間を指します)。
これにより、次の 2 つのエラーが発生します。
- 「型 'Constants.Foo' が見つかりません。型名は大文字と小文字が区別されることに注意してください。」
- 「タイプ 'ns:Constants.Foo' が見つかりませんでした。」
私も試しました:
<Button Content="{Binding Source={x:Static ns:Constants+Foo.Bar}}" />
これにより、1 つのエラーが発生します。
- 「タイプ 'ns:Constants+Foo' が見つかりませんでした。」
静的クラスの静的クラスの静的プロパティにバインドすることは可能ですか? はいの場合、どのように?