// 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 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; }