复选框在Listview中生成。复选框的状态需要存储在本地存储器中。有没有办法将两个单独的列表绑定到一个Listview中。
第一个列表:
List<mergedfeature> mergedfeatures = new List<mergedfeature>();
var res = (from layer in layers
join cat in category
on layer.feature_cat equals cat.id
select new
{
name = cat.category_name,
Mfeatures = layer,
isChecked = true
}).ToList();
Second List:
public int id { get; set; }
public string layer_name { get; set; }
public bool LayerChecked { get; set;}
public string group_name { get; set;}
有没有办法将两个单独的列表绑定到一个Listview中。
第二个列表是否嵌套在第一个列表中?如果是,则可以使用BindableLayout在另一个Listview中显示项的集合。
您可以在BindableLayout.ItemsSource
中绑定内部列表。
你可以在我的演示中参考以下代码:
<ListView x:Name="lstView" RowHeight="60">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal" HorizontalOptions="Fill" BackgroundColor="Olive">
<StackLayout Orientation="Vertical">
<Label Text = "{Binding Name}" FontSize="24" AbsoluteLayout.LayoutBounds="0.25, 0.25, 400, 40"/>
<Label Text = "{Binding Type}" AbsoluteLayout.LayoutBounds="50, 35, 200, 25"/>
</StackLayout>
<Image Source="{Binding Image}" HorizontalOptions="End" AbsoluteLayout.LayoutBounds="250.25, 0.25, 50, 50 "/>
<StackLayout BindableLayout.ItemsSource="{Binding Inner_Items}" Orientation="Horizontal">
<BindableLayout.ItemTemplate>
<DataTemplate>
<StackLayout Orientation="Horizontal">
<Label Text="{Binding layer_name}"/>
<CheckBox IsChecked="{Binding LayerChecked}"/>
</StackLayout>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>