Beispiel #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);
            }
        }
Beispiel #2
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);
            }
        }