问题描述
我是 Xamarin 的新手。
我有 MvxRecyclerView 来显示汽车列表。单击汽车让用户显示所选汽车的完整规格。我在新活动中显示所选汽车的完整规格时遇到问题(同时在视图模型之间传递对象)
我的 MvxRecyclerView .xml 看起来像:
<mvvmcross.droid.support.v7.recyclerview.MvxRecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light"
local:MvxItemTemplate="@layout/listitem_car"
local:MvxBind="ItemsSource Cars; ItemClick NavigateCommand"
/>
我的 CarsViewModel 带有“空”导航到 CarItemViewModel:
public class CarsViewModel : MvxViewModel
{
public CarsViewModel(IMvxNavigationService navigationService)
{
Cars = new MvxObservableCollection<Car>();
_navigationService = navigationService;
NavigateCommand = new MvxAsyncCommand(() => _navigationService.Navigate<CarItemViewModel>());
}
private MvxObservableCollection<Car> _cars;
public MvxObservableCollection<Car> Cars
{
get => _cars;
set
{
_cars = value;
RaisePropertyChanged(() => Cars);
}
}
public override async Task Initialize()
{
await base.Initialize();
CarService carService = new CarService();
await Task.Run(async () =>
{
Cars = await carService.GetCars();
});
}
private readonly IMvxNavigationService _navigationService;
public IMvxAsyncCommand NavigateCommand { get; private set; }
您知道如何使用 MVMCross 将所选 mvxrecyclerview 项目的数据移动到新视图吗?不幸的是,我不明白 MVVMCross 的文档对此有何评论(在我看来它看起来很糟糕)。
我将不胜感激。
编辑 1: 为了更透明,我对问题的描述做了一些更改。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)