This is a migrated thread and some comments may be shown as answers.

Binding SelectionChanged to a ViewModel Command

1 Answer 1197 Views
DataGrid
This is a migrated thread and some comments may be shown as answers.
Kerry
Top achievements
Rank 1
Kerry asked on 24 Nov 2020, 07:37 PM

The only way I can see to do this so far, is to create an event handler in the code behind, then call into the view model from there. But, that seems hokey, from an MVVM perspective.

Is there a simple, straightforward way to set up the command binding from the markup instead?

1 Answer, 1 is accepted

Sort by
0
Lance | Senior Manager Technical Support
Telerik team
answered on 24 Nov 2020, 09:26 PM

Hello Kerry,

For events that do not have a command equivalent, you can use an EventToCommandBehavior. You will find a complete tutorial here Xamarin.Forms - EventToCommand Behavior in MVVM ViewModel (c-sharpcorner.com)

If you would like to see a completed version of that behavior, take a look at one of my custom demos Behaviors folder . In that example, I use an EventToCommandBehavior to invoke a command when the Focused event is invoked, see Lines 22 to 27 here.

Regards,
Lance | Manager Technical Support
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
DataGrid
Asked by
Kerry
Top achievements
Rank 1
Answers by
Lance | Senior Manager Technical Support
Telerik team
Share this question
or