Is it possible to bind two source properties to one control property?

前端 未结 2 1614
轮回少年
轮回少年 2020-12-18 16:42

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 text

相关标签:
2条回答
  • 2020-12-18 17:07

    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.

    0 讨论(0)
  • 2020-12-18 17:26

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

    0 讨论(0)
提交回复
热议问题