I have the following construction:
public static class Constants {
public static class Foo {
public static string Bar {
get {
//Constants.Foo.Bar == "FooBar"
return "FooBar";
}
}
}
}
I want to bind this to a button in a usercontrol.
<Button Content="{Binding Source={x:Static ns:Constants.Foo.Bar}}" />
(where ns points to the assembly and namespace where "Constants" is defined).
This results in two errors:
- "Cannot find the type 'Constants.Foo'. Note that type names are case sensitive."
- "Type 'ns:Constants.Foo' was not found."
I also tried:
<Button Content="{Binding Source={x:Static ns:Constants+Foo.Bar}}" />
This results in one error:
- "Type 'ns:Constants+Foo' was not found."
Is is possible to bind to a static property in a static class in a static class? If yes, how?
this works for me
<Button Content="{Binding Source={x:Static local:Constants+Foo.Bar}}" />
local is
xmlns:local="clr-namespace:WpfTestApp1"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With