Esempio n. 1
0
        public void AddChildrenViews(IList <TabViewChildren> Children)
        {
            grid.Children.Clear();
            grid.ColumnDefinitions.Clear();
            Views.Clear();
            RadioBehaviors.Clear();

            for (int i = 0; i < Children.Count; ++i)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition());
                RadioBehavior radioBehavior = new RadioBehavior()
                {
                    IsChecked = i == 0
                };
                TabViewChildren children = Children[i];
                Views.Add(children.View);
                RadioBehaviors.Add(radioBehavior);
                var tabbedView = new TabbedImageLabelView(children, radioBehavior)
                {
                    Margin = new Thickness(0, 3, 0, 0),
                };
                tabbedView.IndexSelectedChanged += (sendor, e) =>
                {
                    var view  = sendor as TabbedImageLabelView;
                    int index = RadioBehaviors.IndexOf(view.radioBehavior);
                    SelectedChanged?.Invoke(this,
                                            new TabViewChangedEventArgs(index, ChildrenViews[index]));
                };

                grid.Children.Add(tabbedView);
                viewGroup.Children.Add(children.View);
                SetColumn(tabbedView, i);
            }
        }
Esempio n. 2
0
        public TabbedImageLabelView(TabViewChildren tabViewChildren, RadioBehavior radioBehavior)
        {
            InitializeComponent();
            this.tabViewChildren = tabViewChildren;
            this.radioBehavior   = radioBehavior;
            this.Behaviors.Add(radioBehavior);

            this.grid.RowDefinitions[0].Height = tabViewChildren.ImageSize.Height;
            this.image.HeightRequest           = tabViewChildren.ImageSize.Height;
            this.image.WidthRequest            = tabViewChildren.ImageSize.Width;
            this.label.FontSize    = tabViewChildren.TextFontSize;
            this.label.TextColor   = tabViewChildren.UnSelectTextColor;
            this.LabelText         = tabViewChildren.Text;
            this.ImageSource       = tabViewChildren.UnSelectImageSource;
            this.image.ColorFilter = Color.Default;

            var dataTrigger = new DataTrigger(typeof(TabbedImageLabelView))
            {
                Binding = new Binding()
                {
                    Source = radioBehavior,
                    Path   = "IsChecked"
                },
                Value = true,
            };

            dataTrigger.Setters.Add(new Setter()
            {
                Property = LabelColorProperty,
                Value    = tabViewChildren.SelectedTextColor
            });

            dataTrigger.Setters.Add(new Setter()
            {
                Property = ColorFilterProperty,
                Value    = tabViewChildren.ImageColorFilter,
            });

            this.Triggers.Add(dataTrigger);

            tabViewChildren.View.SetBinding(IsVisibleProperty, new Binding()
            {
                Source = radioBehavior,
                Path   = "IsChecked"
            });
        }
Esempio n. 3
0
        public TabView(IList <TabViewChildren> Children)
        {
            InitializeComponent();

            Views          = new List <ContentView>();
            RadioBehaviors = new List <RadioBehavior>();
            //ItemsSource = new ObservableCollection<TabViewChildren>();
            //ItemsSource.CollectionChanged += ItemsSource_CollectionChanged;

            for (int i = 0; i < Children.Count; ++i)
            {
                grid.ColumnDefinitions.Add(new ColumnDefinition());
                RadioBehavior radioBehavior = new RadioBehavior()
                {
                    IsChecked = i == 0
                };
                TabViewChildren children = Children[i];
                Views.Add(children.View);
                RadioBehaviors.Add(radioBehavior);

                var tabbedView = new TabbedImageLabelView(children, radioBehavior)
                {
                    Margin = new Thickness(0, 3, 0, 0),
                };

                tabbedView.IndexSelectedChanged += (sendor, e) =>
                {
                    var view  = sendor as TabbedImageLabelView;
                    int index = RadioBehaviors.IndexOf(view.radioBehavior);
                    SelectedChanged?.Invoke(this,
                                            new TabViewChangedEventArgs(index, Children[index].View));
                };

                grid.Children.Add(tabbedView);
                viewGroup.Children.Add(children.View);
                SetColumn(tabbedView, i);
            }
        }