Hi Carl,
Thanks for contacting Syncfusion Support.
We glad to achieve your requirement " holding selected items using SelectedItems property".
Query: We want to check the chips they has selected before.
SelectedItems is just to hold only the selected items property. If those selected items are removed from its selection, it also removed from SelectedItems property also.
We understood that you need a collection to holds only the previously selected chips. If that means we can get that from SelectionChanged event like in below
[XAML] MainPage.xaml
<StackLayout> <ScrollView> <buttons:SfChipGroup Type="Filter" ItemsSource="{Binding ChipItems}" SelectionChanged="SfChipGroup_SelectionChanged" SelectedItems="{Binding SelectedItems}" DisplayMemberPath="Product"/> </ScrollView> <Label Text="Already selected Chips" Margin="0,10,0,0"/> <ListView ItemsSource="{Binding PreviouslySelectedItems}"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <Label Text="{Binding Product}" /> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView> </StackLayout> |
[C#] MainPage.xaml.cs
private void SfChipGroup_SelectionChanged(object sender, Syncfusion.Buttons.XForms.SfChip.SelectionChangedEventArgs e) { if (!viewModel.PreviouslySelectedItems.Contains(e.AddedItem) && e.AddedItem != null) { viewModel.PreviouslySelectedItems.Add(e.AddedItem as Model); } } |
PreviouslySelectedItems holds only the selected chips from ChipGroup. We have prepared a simple sample to achieve your requirement.
If we misunderstood query, please update us with more details to check further and provide a better solution.
Regards,
Lavanya A.