Xamarin.ios 如何将IReadonlyReactiveList绑定到ReactiveCollectionView

Xamarin.ios 如何将IReadonlyReactiveList绑定到ReactiveCollectionView,xamarin.ios,reactiveui,Xamarin.ios,Reactiveui,我有一个视图模型,它从rest服务检索数据列表,并存储在属性中 private readonly ObservableAsPropertyHelper<IReadOnlyReactiveList<Customer>> _searchResultCustomer; public IReadOnlyReactiveList<Customer> SearchResultCustomer => _searchResultCustomer.Value; priv

我有一个视图模型,它从rest服务检索数据列表,并存储在属性中

private readonly ObservableAsPropertyHelper<IReadOnlyReactiveList<Customer>> _searchResultCustomer;
public IReadOnlyReactiveList<Customer> SearchResultCustomer => _searchResultCustomer.Value;
private readonly ObservableAsPropertyHelper\u searchResultCustomer;
public-IReadOnlyReactiveList SearchResultCustomer=>\u SearchResultCustomer.Value;
我试图在
SearchResultCustomer
ReactiveCollectionView
之间进行绑定,就像这样
this.OneWayBind(ViewModel,vm=>vm.SearchResultCustomer,v=>v.cvResult.DataSource)

毫无疑问,它不起作用,并且
v.cvResult.DataSource
中预期的类型是
IUICollectionViewDataSource


我如何解决这个问题,Xamarin.IOS是否有可用的示例?谢谢:)

绑定到UI集合,如UITableView或UICollectionView,工作方式有点不同。方便的是,您甚至不需要创建自己的UICollectionViewSource。只需使用initialize方法创建一个自定义单元格,并按如下方式绑定:

ViewModel.WhenAnyValue(vm => vm.SearchResultCustomer).BindTo<Customer, CustomerCell>(collectionView, cell => cell.Initialize());
ViewModel.whenyValue(vm=>vm.SearchResultCustomer.BindTo(collectionView,cell=>cell.Initialize());
除了UtableView之外,Paul Reichert回答了一个类似的问题

我分叉了他的示例项目,并为UICollectionView添加了一个工作示例。我使用IReactiveList而不是IReadOnlyReactiveList,但是您应该能够根据需要修改它。这是我的建议。希望能有帮助