4
我有一個包含LocationViewModel
的ObservableCollection的ViewModel。這些在網格中顯示爲瓦片。每個LocationViewModel
存儲一個LocationId
,當單擊網格中的一個圖塊時,它將作爲參數傳遞。單擊某個項目時調用的MvxCommand看起來是這樣的:使用MvxGridView在ItemClick上傳遞參數MvvmCross MvxBind
// 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" />