void Initialize() { BindingContext = _viewModel; NavigationPage.SetHasNavigationBar(this, false); var bg = new Gradient() { Rotation = 150, Steps = new GradientStepCollection() { new GradientStep((Color)Application.Current.Resources["topGradient"], 0), new GradientStep((Color)Application.Current.Resources["bottomGradient"], 1) } }; NavigationPage.SetHasNavigationBar(this, false); ContentPageGloss.SetBackgroundGradient(this, bg); if (Hud.Instance == null) { Hud.Instance = this; } Analytics.TrackEvent($"{GetType().Name} loaded"); }
/// <summary> /// <see cref="T:Xamarin.Forms.Platform.iOS.PageRenderer"/> override that is called whenever the associated /// <see cref="T:Xamarin.Forms.ContentPage"/> instance changes /// </summary> /// <param name="e"><see cref="T:Xamarin.Forms.Platform.iOS.VisualElementChangedEventArgs"/> that specifies the /// previously and newly assigned <see cref="T:Xamarin.Forms.ContentPage"/> instances /// </param> protected override void OnElementChanged(VisualElementChangedEventArgs e) { base.OnElementChanged(e); if (e.OldElement != null) { e.OldElement.PropertyChanging -= OnElementPropertyChanging; e.OldElement.PropertyChanged -= OnElementPropertyChanged; Gradient bkgrndGradient = ContentPageGloss.GetBackgroundGradient(e.OldElement); if (bkgrndGradient != null) { bkgrndGradient.DetachRenderer(this); } } if (e.NewElement != null) { e.NewElement.PropertyChanging += OnElementPropertyChanging; e.NewElement.PropertyChanged += OnElementPropertyChanged; Gradient bkgrndGradient = ContentPageGloss.GetBackgroundGradient(Element); if (bkgrndGradient != null) { bkgrndGradient.AttachRenderer(ContentPageGloss.BackgroundGradientProperty.PropertyName, this); } } }
public MyPage() { var bkgrndGradient = new Gradient() { Rotation = 150, Steps = new GradientStepCollection() { new GradientStep(Color.Red, 0), new GradientStep(Color.White, .25), new GradientStep(Color.Blue, .5), new GradientStep(Color.Green, .75), new GradientStep(Color.BurlyWood, 1), // new GradientStep(Color.FromHex("#ccd9ff"), 1) // new GradientStep(Color.Black, 1) } }; ContentPageGloss.SetBackgroundGradient(this, bkgrndGradient); Content = new StackLayout { Children = { new Label { Text = "Hello ContentPage" } } }; }
/// <summary> /// Private event handler that is called whenever a <see cref="T:Xamarin.Forms.BindableObject.PropertyChanging"/> /// event is fired. /// </summary> /// <param name="sender">Sender.</param> /// <param name="args">Property changing event arguments</param> void OnElementPropertyChanging(object sender, Xamarin.Forms.PropertyChangingEventArgs args) { if (args.PropertyName == ContentPageGloss.BackgroundGradientProperty.PropertyName) { Gradient bkgrndGradient = ContentPageGloss.GetBackgroundGradient(Element); if (bkgrndGradient != null) { bkgrndGradient.DetachRenderer(this); } } }
/// <summary> /// <see cref="T:Xamarin.Forms.Platform.Android.PageRenderer"/> override that is called whenever the /// <see cref="T:Xamarin.Forms.ContentPage.PropertyChanged"/> event is fired /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == ContentPageGloss.BackgroundGradientProperty.PropertyName) { Gradient bkgrndGradient = ContentPageGloss.GetBackgroundGradient(Element); if (bkgrndGradient != null) { bkgrndGradient.AttachRenderer(ContentPageGloss.BackgroundGradientProperty.PropertyName, this); } } }
public AboutPage() { //BackgroundColor = Color.Red; var bkgrndGradient = new Gradient() { Rotation = 150, Steps = new GradientStepCollection() { //new GradientStep(Color.Red, 0), new GradientStep(Color.White, .25), new GradientStep(Color.FromHex("#ccd9ff"), 1) //new GradientStep(Color.Blue, .5), //new GradientStep(Color.Green, .75), //new GradientStep(Color.BurlyWood, 1), // new GradientStep(Color.Black, 1) } }; ContentPageGloss.SetBackgroundGradient(this, bkgrndGradient); this.Title = "Hello in the actual About Page"; Label theLabel = new Label { Text = "About Page : Hello Content Page" }; // var theStack = new StackLayout() // { // //BackgroundColor = Color.Blue, // Children = // { // new Label { Text = "About Page : Hello Content Page"} // } // }; //Content = theStack; Content = theLabel; //Content = new StackLayout //{ // //BackgroundColor = Color.FromHex("555555"), // Children = { // new Label { Text = "Hello ContentPage" } // } //}; }
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 = DeviceExtensions.OnPlatform <double>(176, 232, 0), 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))); }
/// <summary> /// Dispose any created resources and prepare the instance for garbage collection /// </summary> /// <param name="disposing">If set to <c>true</c>, dispose any created resources</param> protected override void Dispose(bool disposing) { if (disposing) { Gradient bkgrndGradient = ContentPageGloss.GetBackgroundGradient(Element); if (bkgrndGradient != null) { bkgrndGradient.DetachRenderer(this); } } base.Dispose(disposing); }
public MainPage() { InitializeComponent(); var bkgrndGradient = new Gradient() { Rotation = 150, Steps = new GradientStepCollection() { new GradientStep(Color.Orange, 0), new GradientStep(Color.Yellow, .25), new GradientStep(Color.Goldenrod, 0.5), new GradientStep(Color.LightYellow, 1) } }; ContentPageGloss.SetBackgroundGradient(this, bkgrndGradient); Data = new ObservableCollection <TemperatureData>(); }
public Charts() { InitializeComponent(); // Manually construct a multi-color gradient at an angle of our choosing var bkgrndGradient = new Gradient() { Rotation = 150, Steps = new GradientStepCollection() { new GradientStep(Color.LightBlue, 0), new GradientStep(Color.SkyBlue, .25), new GradientStep(Color.DeepSkyBlue, .5), new GradientStep(Color.FromHex("#ccd9ff"), 1) } }; ContentPageGloss.SetBackgroundGradient(this, bkgrndGradient); }