I have a ViewModel that includes an ObservableCollection LocationViewModel . They appear as tiles in the grid. Each LocationViewModel stores a LocationId , which is passed as a parameter when you click on a grid element. MvxCommand, called when an item is clicked, looks something like this:
// Constructor public MainViewModel() { LocationSelectedCommand = new MvxCommand<string>(OnLocationSelected); } // MvxCommand calls this private void OnLocationSelected(string locationId) { // Open a new window using 'locationId' parameter }
All this works correctly with WPF. I can bind LocationId as CommandParameter .
<view:LocationTileView Content="{Binding }" Command="{Binding ElementName=groupView, Path=DataContext.LocationSelectedCommand}" CommandParameter="{Binding LocationId}" />
Is there any equivalent syntax in Android for passing a parameter? This does not work, but I'm looking for something like what is in the MvxBind line:
<Mvx.MvxGridView android:layout_width="wrap_content" android:layout_height="match_parent" android:numColumns="5" android:stretchMode="columnWidth" android:verticalSpacing="10dp" android:horizontalSpacing="10dp" local:MvxBind="ItemClick LocationSelectedCommand=LocationId; ItemsSource LocationViewModels" local:MvxItemTemplate="@layout/locationtileview" />
source share