private void ToggleContainer(object sender, EventArgs e)
        {
            var layout = (((Grid)((Grid)sender).Parent).Children[1] as StackLayout);
            var list   = BindableLayout.GetItemsSource(layout) as List <CustomFormQuestion>;

            if (list?.Count > 0)
            {
                (((Grid)((Grid)sender).Parent).Children[1] as StackLayout).IsVisible = !(((Grid)((Grid)sender).Parent).Children[1] as StackLayout).IsVisible;
                if ((((Grid)((Grid)sender).Parent).Children[1] as StackLayout).IsVisible)
                {
                    ((Grid)sender).BackgroundColor = Color.Black;
                    (((Grid)sender).Children[0] as Label).TextColor = Color.FromHex("#fff");
                }
            }
            var parent1 = ((Grid)sender).Parent as Grid;
            var parent2 = parent1.Parent as Frame;
            var parent3 = parent2.Parent as StackLayout;
            var parent4 = parent3.Parent as FlexLayout;

            CurrentQuestion = QuestiontextLabel.Text;
            var list1     = BindableLayout.GetItemsSource(parent4) as List <Answer>;
            var parameter = (e as TappedEventArgs)?.Parameter as Answer;

            list1.First(a => a.ResponseText.ToLower() == parameter.ResponseText.ToLower()).Selected = true;
            list1.Where(a => a.ResponseText.ToLower() != parameter.ResponseText.ToLower()).ForEach(a => a.Selected = false);
            BindableLayout.SetItemsSource(parent4, list1);
            var childrens = parent4.Children;

            foreach (var item in childrens)
            {
                var child      = item as StackLayout;
                var nextChild  = child.Children[0] as Frame;
                var nextChild1 = nextChild.Content as Grid;
                var nextChild2 = nextChild1.Children[0] as Grid;
                var nextChild3 = nextChild2.Children[0] as Label;
                if (nextChild3.Text?.ToLower() != parameter.ResponseText.ToLower())
                {
                    nextChild3.TextColor       = Color.Black;
                    nextChild2.BackgroundColor = Color.Transparent;
                    (nextChild1.Children[1] as StackLayout).IsVisible = false;
                    foreach (var view in (nextChild1.Children[1] as StackLayout).Children)
                    {
                        var stack = view as StackLayout;
                        foreach (var view1 in stack.Children)
                        {
                            var grid   = view1 as Grid;
                            var stack1 = grid.Children[0] as StackLayout;
                            foreach (var view2 in stack1.Children)
                            {
                                var button = view2 as Button;
                                button.BackgroundColor = Color.FromHex("#fff");
                                button.TextColor       = Color.FromHex("#000");
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        public void ValidateBindableProperties()
        {
            var layout = new StackLayout
            {
                IsPlatformEnabled = true,
            };

            // EmptyView
            object emptyView = new object();

            BindableLayout.SetEmptyView(layout, emptyView);

            Assert.AreEqual(emptyView, BindableLayout.GetEmptyView(layout));
            Assert.AreEqual(emptyView, layout.GetValue(BindableLayout.EmptyViewProperty));

            // EmptyViewTemplateProperty
            DataTemplate emptyViewTemplate = new DataTemplate(typeof(Label));

            BindableLayout.SetEmptyViewTemplate(layout, emptyViewTemplate);

            Assert.AreEqual(emptyViewTemplate, BindableLayout.GetEmptyViewTemplate(layout));
            Assert.AreEqual(emptyViewTemplate, layout.GetValue(BindableLayout.EmptyViewTemplateProperty));


            // ItemsSourceProperty
            IEnumerable itemsSource = new object[0];

            BindableLayout.SetItemsSource(layout, itemsSource);

            Assert.AreEqual(itemsSource, BindableLayout.GetItemsSource(layout));
            Assert.AreEqual(itemsSource, layout.GetValue(BindableLayout.ItemsSourceProperty));

            // ItemTemplateProperty
            DataTemplate itemTemplate = new DataTemplate(typeof(Label));

            BindableLayout.SetItemTemplate(layout, itemTemplate);

            Assert.AreEqual(itemTemplate, BindableLayout.GetItemTemplate(layout));
            Assert.AreEqual(itemTemplate, layout.GetValue(BindableLayout.ItemTemplateProperty));


            // ItemTemplateSelectorProperty
            var itemTemplateSelector = new DataTemplateSelectorFrame();

            BindableLayout.SetItemTemplateSelector(layout, itemTemplateSelector);

            Assert.AreEqual(itemTemplateSelector, BindableLayout.GetItemTemplateSelector(layout));
            Assert.AreEqual(itemTemplateSelector, layout.GetValue(BindableLayout.ItemTemplateSelectorProperty));
        }
        private void ToggleContainer(object sender, EventArgs e)
        {
            try
            {
                var senderLayout       = (Frame)((Grid)sender).Parent;
                var senderLayoutParent = (Grid)senderLayout.Parent;
                var layout             = senderLayoutParent.Children[1] as StackLayout;
                var list = BindableLayout.GetItemsSource(layout) as List <CustomFormQuestion>;
                if (list?.Count > 0)
                {
                    (senderLayoutParent.Children[1] as StackLayout).IsVisible = !(senderLayoutParent.Children[1] as StackLayout).IsVisible;
                    if ((senderLayoutParent.Children[1] as StackLayout).IsVisible)
                    {
                        senderLayout.BackgroundColor = Color.Black;
                        (((Grid)sender).Children[0] as Label).TextColor       = Color.FromHex("#fff");
                        (senderLayoutParent.Children[2] as BoxView).IsVisible = true;
                        (senderLayoutParent.Children[3] as BoxView).IsVisible = true;
                    }
                    else
                    {
                        (senderLayoutParent.Children[2] as BoxView).IsVisible = false;
                        (senderLayoutParent.Children[3] as BoxView).IsVisible = false;
                    }
                }

                CurrentActiveResponse = (((Grid)sender).Children[0] as Label).Text;

                var containerParent = (StackLayout)((FlexLayout)((StackLayout)(senderLayoutParent.Parent)).Parent).Parent;
                if (containerParent != null)
                {
                    CurrentActiveQuestionId = ((Label)(containerParent.Children[0])).Text;
                    if (string.IsNullOrEmpty(CurrentActiveQuestionId))
                    {
                        CurrentActiveQuestionId = (((StackLayout)((StackLayout)(containerParent.Parent)).Parent)?.Children[0] as Label)?.Text;
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Пример #4
0
        void OnScrolled(object sender, ScrolledEventArgs e)
        {
            HeroesResponsiveCollectionView scrollView = sender as HeroesResponsiveCollectionView;
            double scrollingSpace = scrollView.ContentSize.Height - scrollView.Height;
            var    source         = BindableLayout.GetItemsSource(stack) as List <Models.Heroes>;

            //if(source?.Count > 50)
            //return;
            if (scrollingSpace <= e.ScrollY)
            {
                //// Touched bottom
                //// Do the things you want to do
                //if (source.Count >= listCount)
                //    return;
                //System.Diagnostics.Debug.WriteLine($"CHUNCK CURRENT VALUE: {i}");
                //var newList = b[i++];
                //System.Diagnostics.Debug.WriteLine($"CHUNCK NEW VALUE: {i}");
                //_heroesList = source.Concat(newList).ToList();
                //BindableLayout.SetItemsSource(stack, _heroesList);
            }
        }