Reputation: 41
We are using Xamarin traditional approach & MVVM Cross.
We want to fire a method which is in the view from ViewModel. What is the best way to achieve it? Is it by IMvxInteraction or MessageCenter?
In another case, we want to fire a method in ViewModel from View. What is the best way to achieve it?
Thanks in advance.
ViewModel
{
func method1()
{
// Trigger a method in iOS View. Which is method2
}
}
iOSView
{
func method2()
{
// Trigger a method in ViewModel. Which is method1
}
}
Upvotes: 0
Views: 630
Reputation: 636
You have to bind your view to a Command in your ViewModel. See how to use ICommand
in https://www.mvvmcross.com/documentation/fundamentals/data-binding.
You may look at Method Binding as well https://www.mvvmcross.com/documentation/plugins/methodbinding.
Upvotes: 1