This question already has an answer here:
In my WPF app I have two textboxes, and I am looking for the following:
I want that if the user writes something on textbox1
the app would put the same value into textbox2
,
<TextBox x:Name="textbox1"/>
<TextBox x:Name="textbox2"/>
Is there an elegant way to do this?
Another alternative for you
This will also do samething
Simple way: C#
The following will work:
Now what this does is that the
Text
property oftextbox2
is bound to theText
property oftextbox1
. Every change you do intextbox1
will automatically be reflected intextbox2
.EDIT: Real Requirements
Based on your comment, here's a solution which might be what you want to do:
and add this C# class:
What I did not show is how to wire up the
MySimpleViewModel
with the actual view. However, if you have problems with that, I can certainly show that as well.Hope it helps.