Support for MVVM Commands rather than traditional code-behind event handlers?

Is it possible to implement the ValueChanged event via MVVM?  

To be clear, what I am asking for is whether or not there is a way to handle the value changed event (likely via a command) in the ViewModel and avoid having to implement a traditional event handler in the code-behind of the Window class.


6 Replies

SC Scott July 30, 2021 01:20 PM UTC

You can disregard this question as I ended up implementing with an interaction trigger and it appears to be working as expected, thanks anyway.



VR Vijayalakshmi Roopkumar Syncfusion Team August 2, 2021 08:55 AM UTC

Hi Scott 
  
Thank you for your update. 
  
We glad that your reported requirement has been solved at your end. 
  
Please let us know if you need any otbher asssitance on this. 
  
Regards, 
Vijayalakshmi VR 



AS Asier February 18, 2023 04:53 PM UTC

I was looking for the same question and I found this Scott post.

I would like to know if it possible to "bind" the Clicked event to a method of my ViewModel class (linked trought the BindingContext) of a simple Syncfusion Button of Xamarin components.


Thank you.



SC Scott replied to Asier February 18, 2023 05:10 PM UTC

 You don't bind to the click event, bind to a command.

submit.PNG

Then in your view model, define the command (you need an implementation of ICommand), in the constructor for the view model wire the command up to the method you want to call, then implement the method.


onsubmit.PNG

method.PNG



AS Asier February 18, 2023 10:25 PM UTC

Thanks. It is the logical way to doit but in the documentation I saw the Clicked event and I don't noticed about the Command property.



VV Vijayakumar Viswanathan Syncfusion Team February 20, 2023 10:49 AM UTC

Hi Asier,

Thank you Scott for sharing the knowledge. 

We are pleased to hear that your query has been resolved. Please do not hesitate to reach out to us if you have any further questions or concerns. We are always happy to assist you.


Loader.
Up arrow icon