Using WPF, is it possible to bind two source properties, via one-way binding, to one control property (ie textbox.text)?? I'd like to have the user input a value in a textbox and have that value pushed to two different properties in the source datacontext. My workaround is to create a dummy property and have the setter set the two values manually.
+3
A:
You need to use a MultiBinding with a IMultiValueConverter. See the example in the documentation
Thomas Levesque
2010-01-04 22:05:37
A:
You could use kind of binding-proxy, as described in this blog post:
http://www.11011.net/wpf-binding-properties
Then just follow these steps for example:
- Define a TextBox with x:Name=tb
- Bind TextBox.Text to Prop1
- Add a Proxy-Element with In="{Binding Text, ElementName=tb}", Out="{Binding Prop2}" (not within but beside the TextBox)
This way, you will have Prop1 and Prop2 synchronized with tb.Text.
Simpzon
2010-01-05 00:02:02