MvvmCross Android – Alternative to RelativeSource binding for button command

See the second option in the answer in MVVMCross changing ViewModel within a MvxBindableListView – this covers one way to do this.

Using that approach you’d expose a list of objects like:

public class Wrapped
{
    public ICommand GoThruCommand { get; set; }
    public ICommand OpenCommand { get; set; }
    public string Name { get; set; }
}

and you’d use an axml list template with bound controls like:

<TextView
    ...
    local:MvxBind="{'Text':{'Path':'Name'}}" />

<Button
    ...
    local:MvxBind="{'Click':{'Path':'GoCommand'}}" />    

<Button
    ...
    local:MvxBind="{'Click':{'Path':'ThruCommand'}}" />    

if you’ve got suggestions/requests for relative source in mvx, please add them to https://github.com/slodge/MvvmCross/issues/35

Leave a Comment