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. Image for the cookie policy date
close icon

SfAccordion Manually Collapse from codebehind


Is there is a way to collapse the content of selected item from code behind?

I have a button in the accordion content and i want to collapse the selected item after finishing its task from MVVC , i do every thing and task run successfully and the accordion header updated succesfully with the updated data , i just need to fire collapse event of this item after finishing the task;


4 Replies

GP Gnana Priya Namasivayam Syncfusion Team December 12, 2019 04:37 PM UTC

Hi Mohammed, 
Thanks for using Syncfusion product. 
Currently, we are validating the reported query from our side. We will validate and provide you further details on December 13,2019. We will appreciate your patience until then. 
Gnana Priya N 

GP Gnana Priya Namasivayam Syncfusion Team December 13, 2019 01:53 PM UTC

Hi Mohammed, 
We would like to inform that you can achieve your requirement binding the IsExpand property of AccordionItem like below. We have attached the model sample based on your requirement. Kindly find the sample and code snippet from below. 
<syncfusion:SfAccordion x:Name="Accordion" ExpandMode="MultipleOrNone" BindableLayout.ItemsSource="{Binding Info}"> 
                <syncfusion:AccordionItem IsExpanded="{Binding IsExpand}"> 
                        <Label Text="{Binding Name}"/> 
                                <RowDefinition Height="50"/> 
                                <RowDefinition Height="50"/> 
                        <Label Text="{Binding Description}"/> 
                            <Button x:Name="btn" Grid.Row="1" Text="{Binding Name}" Command="{Binding Path=BindingContext.ButtonCommand, Source={x:Reference Accordion}}" CommandParameter="{x:Reference btn}"/> 
public class ItemInfoRepository : INotifyPropertyChanged 
        public ObservableCollection<ItemInfo> Info { get; set; } 
        public Command<object> ButtonCommand { get; set; } 
        public ItemInfoRepository() 
            Info = new ObservableCollection<ItemInfo>(); 
            ButtonCommand = new Command<object>(OnButtonTapped); 
        private void OnButtonTapped(object obj) 
            var item = (obj as Button).BindingContext as ItemInfo; 
            item.IsExpand = !item.IsExpand; 
Please let us know whether sample meets your requirement. 
Gnana Priya N 

MO mohamed December 13, 2019 06:08 PM UTC


Thanks alot the sample works and your solustion is just PERFECT for me thanks, that what i was looking  for.

GP Gnana Priya Namasivayam Syncfusion Team December 16, 2019 05:38 AM UTC

Hi Mohammed, 
Thanks for the update. 
We are glad that reported issue have been fixed in your application. Please let us know if you need any further assistance from us. 
Gnana Priya N 

Live Chat Icon For mobile
Up arrow icon