Esempio n. 1
0
        private void InitBodyLayout()
        {
            var layout = new SwipeFrame();

            layout.BackgroundColor = Color.Silver;
            Children.Add(layout, 0, 1);
        }
Esempio n. 2
0
        private void UpdateSwipeFrameLayout()
        {
            var content = ItemTemplate.CreateContent();
            var view    = content as Xamarin.Forms.View;

            if (view == null)
            {
                throw new InvalidOperationException($"DataTemplate returned non-view content: '{content}'.");
            }

            view.Parent = this;

            int index = 0;

            foreach (var item in _itemSource)
            {
                if (index.Equals(SelectedIndex))
                {
                    view.BindingContext = item;
                    break;
                }
                ++index;
            }

            Children.RemoveAt(1);
            _tabLayout            = new SwipeFrame();
            _tabLayout.SwipeLeft += (sender, e) =>
            {
                if ((SelectedIndex + 1).Equals(_count))
                {
                    return;                    //SelectedIndex = 0;
                }
                SelectedIndex++;
            };
            _tabLayout.SwipeRight += (sender, e) =>
            {
                if ((SelectedIndex - 1) < 0)
                {
                    return;                     // SelectedIndex = _count;
                }
                SelectedIndex--;
            };
            _tabLayout.Content = view;
            Children.Add(_tabLayout, 0, 1);


            //TODO
            //update selected tab
            var headerLayout = Children[0] as StackLayout;

            foreach (var i in headerLayout.Children)
            {
                var j = i as TabLayout;
            }
            var c = headerLayout.Children.ElementAt(SelectedIndex) as TabLayout;

            foreach (var child in headerLayout.Children)
            {
                (child as TabLayout).IsSelected      = false;
                (child as TabLayout).BackgroundColor = Color.Silver;
            }
            c.IsSelected      = true;
            c.BackgroundColor = Color.White;
        }