public void DataBind() { var vMainLayout = new StackLayout(); var vFirst = true; if (mDataSource != null) { foreach (var vSingleItem in mDataSource) { var vHeaderButton = new AccordionButton() { Text = vSingleItem.HeaderText, TextColor = vSingleItem.HeaderTextColor, BackgroundColor = vSingleItem.HeaderBackGroundColor }; var vAccordionContent = new ContentView() { Content = vSingleItem.ContentItems, IsVisible = false }; if (vFirst) { vHeaderButton.Expand = mFirstExpaned; vAccordionContent.IsVisible = mFirstExpaned; vFirst = false; } vHeaderButton.AssosiatedContent = vAccordionContent; vHeaderButton.Clicked += OnAccordionButtonClicked; vMainLayout.Children.Add(vHeaderButton); vMainLayout.Children.Add(vAccordionContent); } } mMainLayout = vMainLayout; Content = mMainLayout; }
public void DataBind() { var mainLayout = new StackLayout(); var first = true; if (accordianDataSource != null) { foreach (var singleItem in accordianDataSource) { var headerButton = new AccordionButton() { Text = singleItem.HeaderText, TextColor = singleItem.HeaderTextColor, BackgroundColor = singleItem.HeaderBackGroundColor }; var accordionContent = new ContentView() { Content = singleItem.ContentItems, IsVisible = false }; if (first) { headerButton.Expand = firstExpaned; accordionContent.IsVisible = firstExpaned; first = false; } headerButton.AssosiatedContent = accordionContent; headerButton.Clicked += OnAccordionButtonClicked; mainLayout.Children.Add(headerButton); mainLayout.Children.Add(accordionContent); } } MainLayout = mainLayout; Content = MainLayout; }