Bind Click function with parameter
As MVVM Cross
for Android in Xamarin Studio,
I can write this to a .axml file to bind the click function to the button:
local:MvxBind="Click SendMessage"
SendMessage
is a public method in MvxViewModel with signature
public void SendMessage()
{
//do stuff
}
However, I want to do something like this,
local:MvxBind="Click SendMessage param1: foo, param2: bar"
which should call the method below it with a signature like this,
public void SendMessage(T foo, T bar)
{
//do stuff
}
where foo and bar can be the currently selected item, or an object represented in a specific row in a table, etc.
I don't see anywhere that indicates how to do this and I hope this is native functionality! Can anyone please help?
source to share
The binding mechanism allows you to use either tags ICommand
or public void
. The latter only works if you also install the MethodBinding NuGet package .
As far as the number of options supported, it boils down to a single argument that must match the binding ViewModel
to the item in the ListView.
source to share