How to bind to static property programmatically? What can I use in C# to make
{Binding Source={x:Static local:MyClass.StaticProperty}}
Update: is it possible to do OneWayToSource binding? I understand that TwoWay is not possible because there are no update events on static objects (at least in .NET 4). I cannot instantiate object because it is static.
OneWay binding
Let’s assume that you have class
Countrywith static propertyName.And now you want binding property
NametoTextPropertyofTextBlock.Update: TwoWay binding
Countryclass looks like this:And now we want binding this property
NametoTextBox, so:If you want update target you must use
BindingExpressionand functionUpdateTarget: