如何将项目保持在MvxListView突出显示状态,直到它被取消选中或者直到选择了另一个项目为止?
我的程序有一个MvxListView正确显示项目列表.用户可以通过单击选择项目,然后单击保存按钮.存储所选项目,MyChosenItem直到保存按钮代码需要它为止.当前,所选项目在返回到未选择的颜色之前会在瞬间保持高亮显示.
这是如何MvxListView创建的:
<Mvx.MvxListView
android:layout_width="match_parent"
android:layout_height="260dp"
android:layout_marginTop="40dp"
android:id="@+id/MyMvxListViewControl"
local:MvxBind="ItemsSource MyItems; SelectedItem MyChosenItem"
local:MvxItemTemplate="@layout/my_item_layout" />
Run Code Online (Sandbox Code Playgroud)
这是Layout/my_item_layout.xaml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res/Project.Ui.Droid"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="300.0dp"
android:layout_height="wrap_content"
android:padding="5dp"
android:textSize="20dp"
android:textColor="#000000"
local:MvxBind="Text Field1" />
<TextView
android:layout_width="250.0dp"
android:layout_height="wrap_content"
android:padding="5dp"
android:textSize="20dp"
android:textColor="#000000"
local:MvxBind="Text Field2" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud) 我有一个包含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
}
Run Code Online (Sandbox Code Playgroud)
所有这些都适用于WPF.我可以绑定LocationId一个CommandParameter.
<view:LocationTileView
Content="{Binding }"
Command="{Binding ElementName=groupView, Path=DataContext.LocationSelectedCommand}"
CommandParameter="{Binding LocationId}"
/>
Run Code Online (Sandbox Code Playgroud)
在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" />
Run Code Online (Sandbox Code Playgroud)