How to handle WSPF DataGrid CellEditEnding event in MVVM?

MVVM does not allow the use of code and therefore event handling. So, what MVVM method was notified that the cell was changed?

+5
source share
4 answers

This is a fairly legitimate and obvious question, since there are fairly legitimate solutions to the problem for MVVM. I think someone noted this because it was probably set countless times.

I know that there is something built in for this in .Net4. I'm stuck in .Net3.5, so I'm using the CommandReference class from WPF toolkit to convert an event from a view to a command in view mode.

+1
source

CellEditEnding? , ?

0

; , , " ". , ICommand ViewModel.

( ).

0

"MVVM ".

! .

MVVM , , - Xaml. " " - .

Sometimes handling an event is the easiest and best way to achieve your goal. When this situation, hug it, solve your problem and continue. Sometimes in XAML itโ€™s not even possible to achieve the goal. In these cases, drop the view logic into the code code and move on.

It is much more important to preserve the architectural goals of MVVM (separation of problems between layers) than to strictly follow the rules (for example, to avoid coding). If this distinction is not made, you are short of forest for trees.

-1
source

All Articles