A
A
abasiuk2018-02-08 13:57:53
WPF
abasiuk, 2018-02-08 13:57:53

How to determine event type in WPF MVVM?

For example, a form button has many events like Click, DoubleClick, MouseLeave, etc. In the MVVM approach, you cannot use events, everything is built on commands. But as I understand it, a command for a button is just a click, for a textbox it is a change in content. How to define other events for teams?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav Makarov, 2018-02-08
@Nipheris

I did not understand what you asked and why the textbox has a command to change the content.
There are actions in the application that are conveniently represented in the viewmodel as commands, and for which controls are usually used a la a button (activated / clicked - launched a command). If actions that are convenient in the view model are represented by properties, which are then tied to controls (for example, changing the contents of a text box). I think you need to read more about bindings. Well, or rephrase the question to make it clear.

M
Melz, 2018-02-08
@melz

As a rule, in the MVVM framework there is an EventToCommand or you need to torture Blend.
It is written in the button under
as

EventToCommand Command="{Binding InitializeCommand}" EventName="Loaded"
.
The syntax depends on the framework. For frequent events and bindings, a delay is sometimes set. Parameters are passed through PassEventArgsToCommand (regular arguments), but usually XAML binds the desired value as a parameter to the command.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question