I have a very complicated collection view of items and I would like to have the option to select all or select by skipping items from the binding list. Visually the first select all option is outside of the list. How can I select each item from the list and obtain its properties for example item id?
XAML
<StackLayout x:Name="editview" Grid.Row="3" IsVisible="false">
<CollectionView ItemsSource="{Binding ListData}">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid Padding="10">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label Grid.Column="1"
Text="{Binding subject}"
FontAttributes="Bold" />
<Label Grid.Row="1"
Grid.Column="1"
Text="{Binding body}"
FontAttributes="Italic"
VerticalOptions="End" />
<syncfusion:SfCheckBox x:Name="_checkbox" IsThreeState="True" StateChanged="CheckBox_StateChanged" CornerRadius="5.0"/>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</StackLayout>
C#
void SelectAll_StateChanged(System.Object sender, Syncfusion.XForms.Buttons.StateChangedEventArgs e)
{
if (!skip)
{
skip = true;
New_ListData = vm.ListData;
foreach (var item in New_ListData)
{
NOTE: I DONT HAVE ACCESS TO _checkbox INSIDE THIS. I DONT KNOW WHY?
_checkbox.IsChecked = e.IsChecked;
}
//THEN UPDATE THE COLLECTION VIEW WITH ALL CHECKBOXES TO TRUE
skip = false;
}
}
Aucun commentaire:
Enregistrer un commentaire