我正在使用MvvmCross和UICollectionView。 綁定工作完美,我的所有數據都正確顯示,即使我在CollectionView中選擇一個項目,它也會在我的ViewModel中正確設置。 對於我的SelectedItem使用以下綁定:MvvmCross和UICollectionView如何將SelectedItem從VM綁定到視圖
set.Bind(_collectionViewSource).For(x => x.SelectedItem).To(vm => vm.SelectedMachine);
我唯一的問題是,我想最初選擇的第一CollectionViewItem。 作爲MvvmCross的消息人士說,這不是當前支持(在二傳手的SelectedItem
):
// note that we only expect this to be called from the control/Table
// we don't have any multi-select or any scroll into view functionality here
那麼,什麼是執行項目的初始預選擇的最佳方式?我可以撥打_collectionView.SelectItem
來自哪裏?
我試着在收集改變時調用它,但那似乎不起作用。
謝謝Stuart,我會將其標記爲答案,因爲它是完全正確的。對我來說,我只是愚蠢的使用'NSIndexPath.FromIndex'而不是'NSIndexPath.FromItemSection'。現在使用後者,一切都很好。 – Shaddix