1
votes

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.

2
You're asking two different questions there? Or am I misunderstanding? First you want to use one way binding to your textbox, and then you want to push data back to the source? That's two way... - Aviad P.
I think he wants to bind the textbox.text to two distinct binding sources, s.th.a change in the textbox will change both their values. - Simon D.

2 Answers

5
votes

You need to use a MultiBinding with a IMultiValueConverter. See the example in the documentation

3
votes

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:

  1. Define a TextBox with x:Name=tb
  2. Bind TextBox.Text to Prop1
  3. 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.