5
私はIOSのUICollectionViewに変換するXamarinフォームでカスタムビューを作成しようとしています。XamarinフォームDataTemplateを使用したUICollectionView
この最初のことは行うことは非常に簡単です:
ビュー:
public class CollectionView : View
{
}
レンダラ:
public class CollectionViewRenderer : ViewRenderer<CollectionView, UICollectionView>
{
protected override void OnElementChanged(ElementChangedEventArgs<CollectionView> e)
{
base.OnElementChanged(e);
if (Control == null)
{
SetNativeControl(new UICollectionView(new CGRect(0, 0, 200, 200), new UICollectionViewFlowLayout()));
}
if (e.NewElement != null)
{
...
Control.Source = new CollectionViewSource(a, this);
Control.ReloadData();
}
}
}
今、私は(DataTemplateSelectorから)DataTemplatesでこのCollectionViewを供給したいと思います。 UI要素を取得するために
Template.CreateContent();
:あなたが行うことができますテンプレートから
:しかし、私はクラスを登録する方法を見つけることができないんです。
しかし、どのように私はCollectionSource
例えば:
CollectionView.RegisterClassForCell(typeof(????), "CellId");
こんにちは、リンクをありがとう、それは面白いです。彼らは、セルを登録するのではなく、それらをデキューするだけです。 https://github.com/XLabs/Xamarin-Forms-Labs/blob/master/src/Forms/XLabs.Forms.iOS/Controls/GridView/GridViewRenderer.cs#L89 – RVandersteen
私はあなたがリンクのみの応答。 – RVandersteen
@RVandersteen、私は私の答えを更新しました。 –