views:

141

answers:

2

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
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:

  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.

Simpzon