我们正在使用Xamarin传统方法和MVVM Cross。
我们想触发ViewModel视图中的方法。最好的方法是什么?是通过IMvxInteraction还是MessageCenter?
[在另一种情况下,我们想从View中触发ViewModel中的方法。最好的方法是什么?
提前感谢。
ViewModel
{
func method1()
{
// Trigger a method in iOS View. Which is method2
}
}
iOSView
{
func method2()
{
// Trigger a method in ViewModel. Which is method1
}
}
您必须将视图绑定到ViewModel中的Command。请参阅如何在ICommand
中使用https://www.mvvmcross.com/documentation/fundamentals/data-binding。
您也可以查看方法绑定https://www.mvvmcross.com/documentation/plugins/methodbinding。