Answer the question
In order to leave comments, you need to log in
How to change model from view using textbox?
On the view I have a textbox. I want to make it so that when the text in it changes, the value of the line in the model changes (veiw-model, I'm not doing it strictly). The Text property naturally attached to this line. How can I get the text that I entered in the textbox?
Answer the question
In order to leave comments, you need to log in
<TextBox Text="{Binding UserName, UpdateSourceTrigger=PropertyChanged}" />
I'll add a little to Peter 's
answer (what you need to know about): The binding has a Mode
property that indicates the direction of the binding.
In your case, it is not necessary to write it, because. it is set to the default value (TwoWay), indicating that the binding will be bidirectional - from the model to the view (when the value changes programmatically, it is displayed on the view) and back (when in the view, for example, in the control (in your case TextBox), you change the value, it goes into the bound property of the model)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question