In WPF how to get binding of a specific item from the code?

后端 未结 4 1539
春和景丽
春和景丽 2020-12-10 01:50

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 dat

4条回答
  •  遥遥无期
    2020-12-10 02:10

    I know there's already an accepted answer, but is there some reason you're just not doing this?

    
    
    

    Now whatever textBox1 is bound to, even if that binding changes, textBox2 is as well, no code-behind needed.

    Granted I'm basing this on the XAML as presented, and you very well may need the binding itself from code for something else, but if not, the above works just fine.

提交回复
热议问题