G
G
Georgy Makovetsky2018-03-22 12:49:04
WPF
Georgy Makovetsky, 2018-03-22 12:49:04

How to handle data in wpf textbox, C#?

Hello everyone, without introductions, let's move on to the problem: let's say I have 4 TextBoxes, and the Button button, when clicked, processes the data entered in the TextBoxes. How in the code to transfer to it the very data that was entered? I couldn't find an answer on the internet, maybe I just searched badly.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
eRKa, 2018-03-22
@YtnEtc

It is possible in two ways. The first one is to make the button click event handler in the code in the old fashioned way and take the values ​​from the textboxes inside. The second is to make a binding to the model, in the ground, through the binding attribute, you bind the control to the model and on the button you bind to the command that will take data from the model. This option was mentioned by Stanislav Makarov .

S
Stanislav Makarov, 2018-03-22
@Nipheris

You need a viewmodel, to the properties of which you will bind textboxes and a command sticking out also from this viewmodel, to which you will bind the button. Read about MVVM, ICommand and bindings in WPF.

F
freeExec, 2018-03-22
@freeExec

The form must have links to these TextBoxes and ask them for content.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question