MvvmCross Android - alternative to binding RelativeSource for button command

I have a list of items related to MvxBindableListView with MvxItemTemplate. I usually have 4 items in my list that are tied to my view. The data is updated and the view displays the new data only in order enter image description here .

Now I want to add two buttons to this element template. However, relative source binding is not available with MvvmCross. (see image)

But I am having difficulty developing a solution for this.

I tried binding the ItemClick of a list item, but that only gives me 1 click opportunity and I need 2.

Can anyone help?

+2
source share
1 answer

See the second option in the MVVMCross answer , changing the ViewModel to an MvxBindableListView - this is one way to do this.

Using this approach, you will open a list of objects such as:

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

and you should use the axml list template with related controls, for example:

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

If you have any suggestions / requests regarding a relative source in mvx, add them to https://github.com/slodge/MvvmCross/issues/35

+4
source

All Articles