の ObservableCollection を含む ViewModel がありLocationViewModel
ます。これらは、グリッド内のタイルとして表示されます。それぞれに、グリッド内のタイルがクリックされたときにパラメーターとして渡される がLocationViewModel
格納されます。LocationId
項目がクリックされたときに呼び出される MvxCommand は次のようになります。
// Constructor
public MainViewModel()
{
LocationSelectedCommand = new MvxCommand<string>(OnLocationSelected);
}
// MvxCommand calls this
private void OnLocationSelected(string locationId)
{
// Open a new window using 'locationId' parameter
}
これらはすべて、WPF で正しく機能します。LocationId
としてバインドできCommandParameter
ます。
<view:LocationTileView
Content="{Binding }"
Command="{Binding ElementName=groupView, Path=DataContext.LocationSelectedCommand}"
CommandParameter="{Binding LocationId}"
/>
パラメータを渡すための Android に同等の構文はありますか? これは機能しませんが、MvxBind 行にあるもののようなものを探しています:
<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" />