error:
No constructor found for Xamarin.Forms.Platform.Android.ListViewAdapter::.ctor(System.IntPtr, Android.Runtime.JniHandleOwnership)
必要に迫られ、リストビューの中にリストビューという形をとっています。
iOSで動作させた場合は、どのような状態でも予定通りの動きをしてくれるのですが、
Androidで動作させた時だけListAに2つ以上のデータを入れるとNotSupportedExceptionが出てしまいます。
ListAが1つだけの場合はListBが複数あっても問題なく動きます。
MainActivityは Xamarin.Forms.Platform.Android.FormsAppCompatActivity を継承しています。
page
<StackLayout > <ListView ItemsSource="{Binding ListA}" HasUnevenRows="true" > <ListView.ItemTemplate> <DataTemplate> <ViewCell > <StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"> <Label Text="{Binding TextA.Value}"/> <ListView ItemsSource="{Binding ListB}" > <ListView.ItemTemplate> <DataTemplate> <ViewCell > <StackLayout > <Label Text="{Binding TextB.Value}" /> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView> </StackLayout>
viewModel
public class TestA : BindableBase { public Model.TestList Model { get; set; } = new Model.TestList(); public ReadOnlyReactiveCollection<TestB> ListA { get; } public TestA(Page view) : base(view) { ListA = Model.Tests.ToReadOnlyReactiveCollection(item => { return new TestB(item); }); public class TestB : BindableBase { public Model.TestList.Test Model { get; set; } public ReactiveProperty<string> TextA { get; set; } public ReadOnlyReactiveCollection<TestC> ListB { get; } public TestB(Model.TestList.Test model) { Model = model; TextA = model.ObserveProperty(m => m.TextA).ToReactiveProperty(); ListB = Model.TestItem.ToReadOnlyReactiveCollection(item => { return new TestC(item); }); } public class TestC : BindableBase { public Model.TestList.Test.TestItem Model { get; set; } public ReactiveProperty<string> TextB { get; set; } public TestC(Model.TestList.Test.TestItem model) { Model = model; TextB = Model.ObserveProperty(m => m.TextB).ToReactiveProperty(); } } } } }
誤植あるかもしれません
回答1件
あなたの回答
tips
プレビュー