public HomePage(IndicatorStyleEnum indicatorStyle) { try { viewModel = new SwitcherPageViewModel(); BindingContext = viewModel; Title = _indicatorStyle.ToString(); CustomTabbedView tabbedView = null; switch (indicatorStyle) { case IndicatorStyleEnum.Dots: tabbedView = new DotTabbedView(); break; case IndicatorStyleEnum.Tabs: tabbedView = new TabTabbedView(); break; case IndicatorStyleEnum.None: tabbedView = new TabTabbedView(); break; } tabbedView.CasualLayout.ItemTemplate = new DataTemplate(typeof(HomeView)); Content = tabbedView; } catch (Exception ex) { } }
public HomePage(CarouselLayout.IndicatorStyleEnum indicatorStyle) { _indicatorStyle = indicatorStyle; viewModel = new SwitcherPageViewModel(); BindingContext = viewModel; Title = _indicatorStyle.ToString(); relativeLayout = new RelativeLayout { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; var pagesCarousel = CreatePagesCarousel(); var dots = CreatePagerIndicatorContainer(); _tabs = CreateTabs(); switch (pagesCarousel.IndicatorStyle) { case CarouselLayout.IndicatorStyleEnum.Dots: relativeLayout.Children.Add(pagesCarousel, Constraint.RelativeToParent((parent) => { return(parent.X); }), Constraint.RelativeToParent((parent) => { return(parent.Y); }), Constraint.RelativeToParent((parent) => { return(parent.Width); }), Constraint.RelativeToParent((parent) => { return(parent.Height / 2); }) ); relativeLayout.Children.Add(dots, Constraint.Constant(0), Constraint.RelativeToView(pagesCarousel, (parent, sibling) => { return(sibling.Height - 18); }), Constraint.RelativeToParent(parent => parent.Width), Constraint.Constant(18) ); break; case CarouselLayout.IndicatorStyleEnum.Tabs: var tabsHeight = 50; relativeLayout.Children.Add(_tabs, Constraint.Constant(0), Constraint.RelativeToParent((parent) => { return(parent.Height - tabsHeight); }), Constraint.RelativeToParent(parent => parent.Width), Constraint.Constant(tabsHeight) ); relativeLayout.Children.Add(pagesCarousel, Constraint.RelativeToParent((parent) => { return(parent.X); }), Constraint.RelativeToParent((parent) => { return(parent.Y); }), Constraint.RelativeToParent((parent) => { return(parent.Width); }), Constraint.RelativeToView(_tabs, (parent, sibling) => { return(parent.Height - (sibling.Height)); }) ); break; default: relativeLayout.Children.Add(pagesCarousel, Constraint.RelativeToParent((parent) => { return(parent.X); }), Constraint.RelativeToParent((parent) => { return(parent.Y); }), Constraint.RelativeToParent((parent) => { return(parent.Width); }), Constraint.RelativeToParent((parent) => { return(parent.Height); }) ); break; } Content = relativeLayout; }
public HomePage(CarouselLayout.IndicatorStyleEnum indicatorStyle) { _indicatorStyle = indicatorStyle; viewModel = new SwitcherPageViewModel(); BindingContext = viewModel; Title = _indicatorStyle.ToString(); relativeLayout = new RelativeLayout { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; var pagesCarousel = CreatePagesCarousel(); var dots = CreatePagerIndicatorContainer(); _tabs = CreateTabs(); switch (pagesCarousel.IndicatorStyle) { case CarouselLayout.IndicatorStyleEnum.Dots: relativeLayout.Children.Add(pagesCarousel, Constraint.RelativeToParent((parent) => { return(parent.X); }), Constraint.RelativeToParent((parent) => { return(parent.Y); }), Constraint.RelativeToParent((parent) => { return(parent.Width); }), Constraint.RelativeToParent((parent) => { return(parent.Height / 2); }) ); relativeLayout.Children.Add(dots, Constraint.Constant(0), Constraint.RelativeToView(pagesCarousel, (parent, sibling) => { return(sibling.Height - 18); }), Constraint.RelativeToParent(parent => parent.Width), Constraint.Constant(18) ); break; case CarouselLayout.IndicatorStyleEnum.Tabs: var tabsHeight = 50; relativeLayout.Children.Add(_tabs, Constraint.Constant(0), Constraint.RelativeToParent((parent) => { return(parent.Height - tabsHeight); }), Constraint.RelativeToParent(parent => parent.Width), Constraint.Constant(tabsHeight) ); relativeLayout.Children.Add(pagesCarousel, Constraint.RelativeToParent((parent) => { return(parent.X); }), Constraint.RelativeToParent((parent) => { return(parent.Y); }), Constraint.RelativeToParent((parent) => { return(parent.Width); }), Constraint.RelativeToView(_tabs, (parent, sibling) => { return(parent.Height - (sibling.Height)); }) ); break; default: relativeLayout.Children.Add(pagesCarousel, Constraint.RelativeToParent((parent) => { return(parent.X); }), Constraint.RelativeToParent((parent) => { return(parent.Y); }), Constraint.RelativeToParent((parent) => { return(parent.Width); }), Constraint.RelativeToParent((parent) => { return(parent.Height); }) ); break; } Timer delayTimer = new Timer(); delayTimer.Interval = 5000; delayTimer.Elapsed += (object sender, ElapsedEventArgs e) => { if (pagesCarousel.SelectedIndex > 2) { pagesCarousel.SelectedIndex = 0; } else { pagesCarousel.SelectedIndex = pagesCarousel.SelectedIndex + 1; } }; delayTimer.Start(); Content = relativeLayout; }