The example of this would be:
A textBox is bound to some data. There is a second text box which is not bind to anything. So I want to bind text box 2 to the same data 1st textBox is bound.
In other words I wan't to know if the DependencyObject stores some reference to it's data-bindings? If not, what is the way to find out all data-bindings of a specific object?
A binding source is usually a property on an object so you need to provide both the data source object and the data source property in your binding XAML. In the above example the ElementName attribute signifies that you want data from another element on the page and the Path signifies the appropriate property.
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.
Try this
Xaml
<TextBox Name="textBox1" Text="{Binding Text1}"/> <TextBox Name="textBox2" Text="No Binding"/>
Then we can set the binding of the TextProperty for textBox2 to the same as textBox1 with this code behind
BindingExpression bindingExpression = textBox1.GetBindingExpression(TextBox.TextProperty); Binding parentBinding = bindingExpression.ParentBinding; textBox2.SetBinding(TextBox.TextProperty, parentBinding);
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