In MVVM Cross for Android in Xamarin Studio,
I can write this in my .axml file to bind a click function to a button:
local:MvxBind="Click SendMessage"
SendMessage is a public method on the MvxViewModel with the signature
public void SendMessage()
{
//do stuff
}
However, I want to do something like like this,
local:MvxBind="Click SendMessage param1: foo, param2: bar"
which should call the method underneath with a signature like this,
public void SendMessage(T foo, T bar)
{
//do stuff
}
where foo and bar might be the current selected item, or the object represented in a particular row of a table etc.
I can't see anywhere that points towards how to do this, and I am hoping that it is a native functionality! Can anyone help?
The binding engine allows you to use either ICommand instances or public void methods. The latter only works if you also install the NuGet package MethodBinding.
As for the amount of parameters supported, it boils down to a single argument, which should correspond to the ViewModel bound to the item in the ListView.
You can use an ICommand instead of a void to execute your code, here you can paas one parameter.
An other option is to bind the parameters you need to objects and access these objects in your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With