Exemple #1
0
        private void OnAccordionExtendedContentButtonClicked(AccordionExtendedContentButton sender)
        {
            var senderButton = (AccordionExtendedContentButton)sender;

            if (!senderButton.Expand)
            {
                foreach (var childItem in mainLayout.Children)
                {
                    if (childItem.GetType() == typeof(ContentView))
                    {
                        childItem.IsVisible = false;
                    }
                    if (childItem.GetType() == typeof(AccordionExtendedContentButton))
                    {
                        var button = (AccordionExtendedContentButton)childItem;
                        button.Expand = false;
                    }
                }

                if (senderButton.Expand)
                {
                    senderButton.Expand = false;
                }
                else
                {
                    senderButton.Expand = true;
                }

                senderButton.AssosiatedContent.IsVisible = senderButton.Expand;
            }
        }
Exemple #2
0
        public void DataBind()
        {
            mainLayout = new StackLayout();
            var layout     = new StackLayout();
            var first      = true;
            var firstOuter = FirstExpaned;

            if (DataSource != null)
            {
                foreach (var singleItem in DataSource)
                {
                    var titleButton = new AccordionExtendedMainButton()
                    {
                        Text                = singleItem.Title ?? "",
                        ButtonStyle         = singleItem.TitleStyle,
                        ButtonDefaultStyle  = singleItem.TitleStyle,
                        ButtonSelectedStyle = singleItem.TitleSelectedStyle,
                        HorizontalOptions   = LayoutOptions.FillAndExpand
                    };
                    titleButton.Expand   = firstOuter;
                    titleButton.Clicked += OnAccordionExtendedMainButtonClicked;
                    layout.Children.Add(titleButton);
                    foreach (var accordionExtendedSourceItem in singleItem.AccordionExtendedSourceItems)
                    {
                        var headerButton = new AccordionExtendedContentButton()
                        {
                            Text              = accordionExtendedSourceItem.HeaderText,
                            TextStyle         = accordionExtendedSourceItem.HeaderTextStyle,
                            TextDefaultStyle  = accordionExtendedSourceItem.HeaderTextStyle,
                            TextSelectedStyle = accordionExtendedSourceItem.HeaderTextSelectedStyle,

                            ImageSource         = accordionExtendedSourceItem.HeaderImage,
                            ImageDefaultSource  = accordionExtendedSourceItem.HeaderImage,
                            ImageSelectedSource = accordionExtendedSourceItem.HeaderImageSelected,
                            ImageStyle          = accordionExtendedSourceItem.HeaderImageStyle,

                            NotePart1      = accordionExtendedSourceItem.HeaderNotePart1,
                            NotePart2      = accordionExtendedSourceItem.HeaderNotePart2,
                            NotePart3      = accordionExtendedSourceItem.HeaderNotePart3,
                            NoteStyle      = accordionExtendedSourceItem.HeaderNoteStyle,
                            NotePart2Style = accordionExtendedSourceItem.HeaderNotePart2Style
                        };
                        headerButton.IsVisible = firstOuter;
                        var accordionExtendedContent = new ContentView()
                        {
                            Content   = accordionExtendedSourceItem.ContentItems,
                            IsVisible = false
                        };
                        if (first)
                        {
                            headerButton.IsVisible             = firstExpaned;
                            headerButton.Expand                = firstExpaned;
                            accordionExtendedContent.IsVisible = firstExpaned;
                            first = false;
                        }

                        headerButton.AssosiatedContent = accordionExtendedContent;
                        headerButton.GestureRecognizers.Add(new TapGestureRecognizer()
                        {
                            Command = new Command(() => { OnAccordionExtendedContentButtonClicked(headerButton); })
                        });
                        titleButton.AccordionExtendedButtons.Add(headerButton);
                        layout.Children.Add(headerButton);
                        layout.Children.Add(accordionExtendedContent);
                    }

                    firstOuter = false;
                }
            }

            mainLayout = layout;
            Content    = mainLayout;
        }