public Example_NestedCarousels()
        {
            #region Carousel Code

            // Initialise a new Carousel layout
            _carousel = new ManualCarouselView {
                Pages = new List<Layout> (),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var nestedCarousel = GenerateCarousel(); // Generate our Nested Carousel
            AddPageToParentCarousel(_carousel, nestedCarousel); // Add the generated
            _carousel.Pages.Add (CreatePage (Color.Maroon, Color.White, new Label() { Text = "Parent Carousel\nPage 2:\n" + ExampleStrings.ILikeDogs, TextColor = Color.White }, _carousel));

            // Finally initialise it, this sets the starting page and calculates the size, etc.
            _carousel.Initialise (0);

            #endregion

            Title = "Nested Carousels";

            // Finally, assign the carousel as the page content.
            Content = _carousel;
        }
 public void AddPagesToCarousel(ManualCarouselView carousel)
 {
     // Add content pages to the carousel (in this instance, the buttons are nested within the carousel)
     carousel.Pages.Add (CreatePage (Color.Maroon, Color.White, "Page 1\n" + ExampleStrings.ILikeDogs, carousel ));
     carousel.Pages.Add (CreatePage (Color.Navy, Color.White, "Page 2\n" + ExampleStrings.WaterMovesFast, carousel ));
     carousel.Pages.Add (CreatePage (Color.White, Color.Black, "Page 3\n" + ExampleStrings.LysineContingency, carousel ));
 }
        public Grid CreatePage(Color bgColor, Color textColor, string text, ManualCarouselView eventTarget)
        {
            Grid content = new Grid {
                ColumnDefinitions = new ColumnDefinitionCollection {
                    new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) },
                    new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) },
                    new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) }
                },
                RowDefinitions = new RowDefinitionCollection{
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }
                },
                BackgroundColor = bgColor
            };

            Button goBack = new Button () {
                Text = "Back",
                TextColor = textColor,
                Command = new Command(() => {
                    Device.BeginInvokeOnMainThread(() => {
                        eventTarget.AdvancePage(-1);
                    });
                })
            };

            Button goForward = new Button () {
                Text = "Next",
                TextColor = textColor,
                Command = new Command(() => {
                    Device.BeginInvokeOnMainThread(() => {
                        eventTarget.AdvancePage(1);
                    });
                })
            };

            Label textcontent = new Label () {
                TextColor = textColor,
                Text = text,
                XAlign = TextAlignment.Center,
                YAlign = TextAlignment.Center
            };

            content.Children.Add (goBack, 0, 1, 3, 4);
            content.Children.Add (goForward, 2, 3, 3, 4);
            content.Children.Add (textcontent, 0, 3, 0, 3);

            return content;
        }
        // Here we create basic pages for the views, only we specify the content to display in the main area
        // We also specify which CarouselView we wish to manipulate by passing it in.
        public Grid CreatePage(Color bgColor, Color textColor, View content, ManualCarouselView eventTarget)
        {
            Grid layout = new Grid {
                ColumnDefinitions = new ColumnDefinitionCollection {
                    new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) },
                    new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) },
                    new ColumnDefinition{ Width = new GridLength (1, GridUnitType.Star) }
                },
                RowDefinitions = new RowDefinitionCollection{
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }
                },
                BackgroundColor = bgColor
            };

            Button goBack = new Button () {
                Text = "Back",
                TextColor = textColor,
                Command = new Command(() => {
                    Device.BeginInvokeOnMainThread(() => {
                        if (eventTarget != null) {
                            eventTarget.AdvancePage(-1);
                        }
                    });
                })
            };

            Button goForward = new Button () {
                Text = "Next",
                TextColor = textColor,
                Command = new Command(() => {
                    Device.BeginInvokeOnMainThread(() => {
                        if (eventTarget != null) {
                            eventTarget.AdvancePage(1);
                        }
                    });
                })
            };

            if (eventTarget != null) {
                layout.Children.Add (goBack, 0, 1, 3, 4);
                layout.Children.Add (goForward, 2, 3, 3, 4);
            }
            layout.Children.Add (content, 0, 3, 0, 3);

            return layout;
        }
        public Example_FullPage()
        {
            #region Carousel Code

            // Initialise a new Carousel layout
            _carousel = new ManualCarouselView {
                Pages = new List<Layout> (),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            AddPagesToCarousel (_carousel);

            // Finally initialise it, this sets the starting page and calculates the size, etc.
            _carousel.Initialise (0);

            #endregion

            // Set the page title
            Title = "Full Page Carousel";

            // Finally, assign the carousel as the page content.
            Content = _carousel;
        }
        private View GenerateLayout()
        {
            _baseLayout = new Grid () {
                ColumnDefinitions = new ColumnDefinitionCollection{
                    new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
                    new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }
                },
                RowDefinitions = new RowDefinitionCollection {
                    new RowDefinition { Height = new GridLength(_dimensions.Value.X / 2, GridUnitType.Absolute) },
                    new RowDefinition { Height = new GridLength(_dimensions.Value.X / 2, GridUnitType.Absolute) },
                    new RowDefinition { Height = new GridLength(_dimensions.Value.X / 2, GridUnitType.Absolute) },
                    new RowDefinition { Height = new GridLength(_dimensions.Value.X / 2, GridUnitType.Absolute) }
                }
            };

            box1 = new ManualCarouselView{ Pages = new List<Layout>() }; // LiveTile
            box2 = new ContentView{ BackgroundColor = Color.Green }; // Boring Tile
            box3 = new ManualCarouselView{ Pages = new List<Layout>() }; // Double-Width Live-Tile
            box4 = new ManualCarouselView{ Pages = new List<Layout>() }; // Double-Height Live-Tile
            box5 = new ContentView{ BackgroundColor = Color.Blue }; // Double-Height boring tile

            SetupBox1(box1);
            SetupBox2(box2);
            SetupBox3(box3);
            SetupBox4(box4);
            SetupBox5(box5);

            _baseLayout.Children.Add (box1, 0, 1, 0, 1);
            _baseLayout.Children.Add (box2, 1, 2, 0, 1);
            _baseLayout.Children.Add (box3, 0, 2, 1, 2);
            _baseLayout.Children.Add (box4, 0, 1, 2, 4);
            _baseLayout.Children.Add (box5, 1, 2, 2, 4);

            return new ScrollView {
                Orientation = ScrollOrientation.Vertical,
                Content = _baseLayout,
            };
        }
        private void SetupBox4(ManualCarouselView box)
        {
            int timesTileHasChanged = 0;

            Label lb1 = new Label {
                TextColor = Color.White,
                FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
                Text = ExampleStrings.LiveTile4[0]
            };
            Label lb2 = new Label {
                TextColor = Color.White,
                FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
                Text = ExampleStrings.LiveTile4[0] + "\n\n" + ExampleStrings.LiveTile4[1]
            };
            CarouselPage pg1 = new CarouselPage {
                Padding = new Thickness(5),
                BackgroundColor = Color.FromHex("#FF7C2E"),
                Content = lb1,

            };
            CarouselPage pg2 = new CarouselPage{
                Padding = new Thickness(5),
                BackgroundColor = Color.FromHex("#8C3500"),
                Content = lb2
            };

            // If you extend the standard layout classes to implement the IManualCarouselPage interface
            // Then you can tie events to when the pages change.
            pg1.PageAppearing += () => {
                Device.BeginInvokeOnMainThread(() => {
                    lb1.Text = String.Format("{0} {1}", ExampleStrings.LiveTile4[0], ++timesTileHasChanged);
                });
            };
            pg2.PageAppearing += () => {
                Device.BeginInvokeOnMainThread(() => {
                    lb2.Text = String.Format("{0} {1}\n\n{2}", ExampleStrings.LiveTile4[0], ++timesTileHasChanged, ExampleStrings.LiveTile4[1]);
                });
            };

            box.Pages.Add (pg1);
            box.Pages.Add (pg2);
            box.Initialise (0);
        }
        private void SetupBox3(ManualCarouselView box)
        {
            Label lb1 = new Label {
                TextColor = Color.Black,
                Text = ExampleStrings.LiveTile3[0]
            };
            Label lb2 = new Label {
                TextColor = Color.White,
                Text = ExampleStrings.LiveTile3[1]
            };
            ContentView pg1 = new ContentView {
                Padding = new Thickness(5),
                BackgroundColor = Color.FromHex("#92E9DC"),
                Content = lb1
            };
            ContentView pg2 = new ContentView{
                Padding = new Thickness(5),
                BackgroundColor = Color.FromHex("#399A8C"),
                Content = lb2
            };

            box.Pages.Add (pg1);
            box.Pages.Add (pg2);
            box.Initialise (0);
        }
        public ManualCarouselView GenerateCarousel()
        {
            ManualCarouselView carousel = new ManualCarouselView {
                Pages = new List<Layout> (),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            AddPagesToCarousel(carousel);

            carousel.Initialise (0);

            return carousel;
        }
 public void AddPageToParentCarousel(ManualCarouselView carousel, ManualCarouselView nestedCarousel)
 {
     // Add content pages to the carousel (in this instance, the buttons are nested within the carousel)
     carousel.Pages.Add (CreatePage (Color.Maroon, Color.White, nestedCarousel, carousel));
 }