I would like to have one (global, singleton) object in my application that exposes a number of dependency properties. I would like to bind values in XAML to these dependency properties. How can I achieve this so that the syntax of my XAML binding is as simple as possible (in other words, not constantly worrying about RelativeSource, AncestoryType, etc).
Data binding is a mechanism in XAML applications that provides a simple and easy way for Windows Runtime Apps using partial classes to display and interact with data. The management of data is entirely separated from the way the data is displayed in this mechanism.
Two way binding is used when we want to update some controls property when some other related controls property change and when source property change the actual control also updates its property.
You can use the x:Static markup extension to bind directly to your Singleton, as it's a static property.
For example, if your singleton had a property named "Foo":
<TextBox Text="{x:Static local:YourSingleton.Instance.Foo}" />
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