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

Accordion view expand accordion from vm

I have an accordion that i am populating data from a viewmodel. How would i expand one accordion from the viewmodel? 

As an example, i am populating an accordion with weekly data sunday - saturday, I want to expand the accordion to whatever day today is, say Tuesday.




3 Replies

LN Lakshmi Natarajan Syncfusion Team February 3, 2020 10:11 AM UTC

Hi Reza, 
 
Thank you for using Syncfusion products. 
 
We have checked the reported query from our end. We would like to let you know that you can expand one AccordionItem based on IsExpanded property by using ExpandMode as Single when loaded. Please find the following code snippet for more reference, 
 
Xaml: 
 
<accordion:SfAccordion x:Name="accordion" 
                               BindableLayout.ItemsSource="{Binding Info}"  
                               ExpandMode="Single"> 
            <BindableLayout.ItemTemplate> 
                <DataTemplate> 
                    <accordion:AccordionItem IsExpanded="{Binding IsExpanded}"> 
                        <accordion:AccordionItem.Header> 
                            <Grid> 
                                <Label Grid.Row="0" 
                                        Text="{Binding Name}" 
                                        TextColor="Black" 
                                        FontAttributes="Bold" 
                                        FontSize="20" /> 
                            </Grid> 
                        </accordion:AccordionItem.Header> 
                        <accordion:AccordionItem.Content> 
                            <Grid HeightRequest="50"> 
                                <Label Text="{Binding Description}"/> 
                            </Grid> 
                        </accordion:AccordionItem.Content> 
                    </accordion:AccordionItem> 
                </DataTemplate> 
            </BindableLayout.ItemTemplate> 
        </accordion:SfAccordion> 
 
We have prepared a sample based on your requirement. Please find the sample in the following link, 
 
 
You can also refer our online user guide documentation regarding the same by the following link, 
 
 
We hope this helps. Please let us know if you need any further assistance. 
 
Regards, 
Lakshmi Natarajan 



RE Reza February 4, 2020 04:05 AM UTC

Thank you! Exactly what I was needing help with.


LN Lakshmi Natarajan Syncfusion Team February 4, 2020 04:45 AM UTC

Hi Reza, 
 
Thanks for the update. 
  
We are glad that reported issue have been resolved at your end. Please let us know if you need any further update. As always we are happy to help you out. 
 
Regards, 
Lakshmi Natarajan 


Loader.
Up arrow icon