public BackgroundColorPage() { /* * This is a bit of a hack. Android's renderer for TableView always adds an empty header for a * TableSection declaration, while iOS doesn't. To compensate, I'm using a Label to display info text * on iOS, and the TableSection on Android since there is no easy way to get rid of it.This is a * long-standing bug in the XF TableView on Android. * (https://forums.xamarin.com/discussion/18037/tablesection-w-out-header) */ TableSection section; if (Device.RuntimePlatform == Device.Android) { section = new TableSection("Cell BackgroundColor values set in C#:"); } else { section = new TableSection(); } var cell = new TextCell { Text = "Red", TextColor = Color.White }; CellGloss.SetBackgroundColor(cell, Color.Red); section.Add(cell); cell = new TextCell { Text = "Green", TextColor = Color.White }; CellGloss.SetBackgroundColor(cell, Color.Green); section.Add(cell); cell = new TextCell { Text = "Blue", TextColor = Color.White }; CellGloss.SetBackgroundColor(cell, Color.Blue); section.Add(cell); var stack = new StackLayout(); if (Device.RuntimePlatform == Device.iOS) { stack.Children.Add(new Label { Text = "Cell BackgroundColor values set in C#:", Margin = new Thickness(10) }); } stack.Children.Add(new TableView { Intent = TableIntent.Data, HeightRequest = XFGlossDevices.OnPlatform <double>(132, 190), Root = new TableRoot { section } }); Content = stack; }
protected override void OnBindingContextChanged() { base.OnBindingContextChanged(); /* * This is a bit of a hack. Android's renderer for TableView always adds an empty header for a * TableSection declaration, while iOS doesn't. To compensate, I'm using a Label to display info text * on iOS, and the TableSection on Android since there is no easy way to get rid of it.This is a * long-standing bug in the XF TableView on Android. * (https://forums.xamarin.com/discussion/18037/tablesection-w-out-header) */ TableSection section; if (Device.RuntimePlatform == Device.Android) { section = new TableSection("Cell BackgroundGradient values set in C#:"); } else { section = new TableSection(); } section.Add(CreateBackgroundGradientCells()); var stack = new StackLayout(); if (Device.RuntimePlatform == Device.iOS) { stack.Children.Add(new Label { Text = "Cell BackgroundGradient values set in C#:", Margin = new Thickness(10) }); } stack.Children.Add(new TableView { Intent = TableIntent.Data, BackgroundColor = Color.Transparent, VerticalOptions = LayoutOptions.Start, HeightRequest = XFGlossDevices.OnPlatform <double>(176, 232), Root = new TableRoot { section } }); stack.Children.Add(new Label { Text = "ContentPage BackgroundGradient value set in C#:", Margin = new Thickness(10) }); Content = stack; // Set the page's background gradient ContentPageGloss.SetBackgroundGradient(this, new Gradient(Color.White, Color.FromRgb(128, 0, 0))); }
public ThumbTintColorPage() { /* * This is a bit of a hack. Android's renderer for TableView always adds an empty header for a * TableSection declaration, while iOS doesn't. To compensate, I'm using a Label to display info text * on iOS, and the TableSection on Android since there is no easy way to get rid of it.This is a * long-standing bug in the XF TableView on Android. * (https://forums.xamarin.com/discussion/18037/tablesection-w-out-header) */ TableSection section; if (Device.RuntimePlatform == Device.Android) { section = new TableSection("SwitchCell ThumbTintColor values set in C#:"); } else { section = new TableSection(); } section.Add(CreateThumbTintColorCell("Red", Color.Red)); section.Add(CreateThumbTintColorCell("Green", Color.Green)); section.Add(CreateThumbTintColorCell("Blue", Color.Blue)); var stack = new StackLayout { Padding = 10 }; // Slider demo stack.Children.Add(new Label { Text = "Slider ThumbTintColor values set in C#", Margin = new Thickness(10) }); stack.Children.Add(CreateThumbTintColorSlider(25, Color.Red)); stack.Children.Add(CreateThumbTintColorSlider(50, Color.Green)); stack.Children.Add(CreateThumbTintColorSlider(75, Color.Blue)); if (Device.RuntimePlatform == Device.iOS) { stack.Children.Add(new Label { Text = "SwitchCell ThumbTintColor values set in C#:", Margin = new Thickness(10) }); } stack.Children.Add(new TableView() { HeightRequest = XFGlossDevices.OnPlatform <double>(132, 190), Root = new TableRoot() { section } }); stack.Children.Add(new Label() { Text = "Switch ThumbTintColor values set in C#:", Margin = 10 }); stack.Children.Add(CreateThumbTintColorSwitch("Red", Color.Red)); stack.Children.Add(CreateThumbTintColorSwitch("Green", Color.Green)); stack.Children.Add(CreateThumbTintColorSwitch("Blue", Color.Blue)); Content = new ScrollView() { Content = stack }; }
protected override void OnBindingContextChanged() { base.OnBindingContextChanged(); var stack = new StackLayout(); if (Device.RuntimePlatform == Device.iOS) { stack.Children.Add( new StackLayout { Spacing = 0, IsVisible = (BindingContext as TintColorViewModel).isRunningiOS, Children = { new Label() { Text = "Cell accessory TintColor values set in C#:", Margin = 10 }, new TableView() { HeightRequest = 132, Root = new TableRoot() { new TableSection() { CreateTintColorCell("Red", Color.Red, CellGlossAccessoryType.Checkmark), CreateTintColorCell("Green", Color.Green, CellGlossAccessoryType.Checkmark), CreateTintColorCell("Blue", Color.Blue, CellGlossAccessoryType.EditIndicator) } } } } }); stack.Children.Add( new Label() { Text = "SwitchCell TintColor values set in C#:", Margin = 10 }); } /* * This is a bit of a hack. Android's renderer for TableView always adds an empty header for a * TableSection declaration, while iOS doesn't. To compensate, I'm using a Label to display info text * on iOS, and the TableSection on Android since there is no easy way to get rid of it.This is a * long-standing bug in the XF TableView on Android. * (https://forums.xamarin.com/discussion/18037/tablesection-w-out-header) */ TableSection section; if (Device.RuntimePlatform == Device.Android) { section = new TableSection("SwitchCell TintColor values set in C#:"); } else { section = new TableSection(); } section.Add(CreateTintColorSwitchCell("Red", Color.Red)); section.Add(CreateTintColorSwitchCell("Green", Color.Green)); section.Add(CreateTintColorSwitchCell("Blue", Color.Blue)); stack.Children.Add( new TableView() { Intent = TableIntent.Data, HeightRequest = XFGlossDevices.OnPlatform <double>(132, 190), Root = new TableRoot() { section } }); stack.Children.Add( new Label() { Text = "Switch TintColor values set in C#:", Margin = 10 }); stack.Children.Add(CreateTintColorSwitch("Red", Color.Red)); stack.Children.Add(CreateTintColorSwitch("Green", Color.Green)); stack.Children.Add(CreateTintColorSwitch("Blue", Color.Blue)); if (Device.RuntimePlatform == Device.iOS) { var scrollView = new ScrollView(); scrollView.Content = stack; Content = scrollView; } else { Content = stack; } }