We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Using Filter type and need to set some chips to be checked programatically

Thread ID:

Created:

Updated:

Platform:

Replies:

145248 Jun 13,2019 03:42 PM UTC Jun 17,2019 05:52 AM UTC Xamarin.Forms 3
loading
Tags: SfChipGroup
Carl Barton
Asked On June 13, 2019 03:42 PM UTC

I am using SfChipGroup in order to create a filter in our app. In our app, the user will tap the ones they want and then save. We are grabbing all of the selected chips from SelectedItems and then storing that for future use. That would fine.

What we are not able to do is when the user goes back to the group we want to check the chips that they had selected before. Setting SfChipGroup.Items[x].IsChecked does not seem to do anything.

How can we make this work?

Carl


Lavanya Anaimuthu [Syncfusion]
Replied On June 15, 2019 03:42 PM UTC

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. 


Carl Barton
Replied On June 15, 2019 04:56 PM UTC

Thanks. That will work fine for me. 

Muneesh Kumar G [Syncfusion]
Replied On June 17, 2019 05:52 AM UTC

Hi Carl,  
 
Thanks for the update. 
  
We are glad to know that the given solution works. Please let us know if you need any further assistance. 
 
Thanks, 
Muneesh Kumar G. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon