public GettingStartedSample() { InitializeComponent(); if (Device.RuntimePlatform == Device.WPF) { iconButtonLeft.ImageSource = "button_Heart.png"; iconButtonRight.ImageSource = "button_Heart.png"; SfLinearGradientBrush linearGradientBrush = new SfLinearGradientBrush(); linearGradientBrush.GradientStops = new Syncfusion.XForms.Graphics.GradientStopCollection() { new SfGradientStop() { Color = Color.FromHex("#2F9BDF"), Offset = 0 }, new SfGradientStop() { Color = Color.FromHex("#51F1F2"), Offset = 1 } }; gradientButton.FontSize = 14; gradientButton.BackgroundGradient = linearGradientBrush; SetDefaultSize(); } if (Device.RuntimePlatform == Device.UWP) { SetDefaultSize(); } }
/// <summary> /// Add the linear gradient brushes. /// </summary> /// <param name="color1">color1</param> /// <param name="color2">color2</param> /// <param name="offset1">offset1</param> /// <param name="offset2">offset2</param> /// <returns>linear gradient</returns> private SfLinearGradientBrush AddLinearGradient(string color1, string color2, int offset1, int offset2) { SfLinearGradientBrush gradient1 = new SfLinearGradientBrush(); gradient1.StartPoint = new Point(0.5, 0); gradient1.EndPoint = new Point(0.5, 1); gradient1.GradientStops.Add(new SfGradientStop() { Color = Color.FromHex(color1), Offset = offset1 }); gradient1.GradientStops.Add(new SfGradientStop() { Color = Color.FromHex(color2), Offset = offset2 }); return(gradient1); }
private SfLinearGradientBrush GetGradients(Color startColor, Color endColor) { SfLinearGradientBrush linearGradientBrush = new SfLinearGradientBrush(); linearGradientBrush.GradientStops = new Syncfusion.XForms.Graphics.GradientStopCollection() { new SfGradientStop() { Color = startColor, Offset = 0.0 }, new SfGradientStop() { Color = endColor, Offset = 1.0 }, }; return(linearGradientBrush); }
/// <summary> /// Toggle between linear and radial gradient. /// </summary> /// <param name="sender">segmented control</param> /// <param name="e">event arguments</param> private void ToggleButton_SelectionChanged(object sender, Syncfusion.XForms.Buttons.SelectionChangedEventArgs e) { var viewModel = (this.BindingContext as GettingStartedViewModel); var chip = chipControl; if (e.Index == 0) { gradientAngle.Text = "\xe702"; SfLinearGradientBrush brush = viewModel.LinearGradientBrushes[chipSelectedIndex]; brush.StartPoint = startPoint; brush.EndPoint = endPoint; viewModel.BackgroundGradient = brush; } else { gradientAngle.Text = "\xe701"; viewModel.BackgroundGradient = viewModel.RadialGradientBrushes[chipSelectedIndex]; rotationAngle = 0; startPoint = new Point(0.5, 0); endPoint = new Point(0.5, 1); } }
private void GradientButton_Clicked(object sender, System.EventArgs e) { if (Device.RuntimePlatform == Device.WPF) { SfLinearGradientBrush linearGradientBrush = new SfLinearGradientBrush(); if (gradientButton.IsChecked == true) { linearGradientBrush.GradientStops = new Syncfusion.XForms.Graphics.GradientStopCollection() { new SfGradientStop() { Color = Color.FromHex("#51F1F2"), Offset = 0 }, new SfGradientStop() { Color = Color.FromHex("#2F9BDF"), Offset = 1 } }; } else { linearGradientBrush.GradientStops = new Syncfusion.XForms.Graphics.GradientStopCollection() { new SfGradientStop() { Color = Color.FromHex("#2F9BDF"), Offset = 0 }, new SfGradientStop() { Color = Color.FromHex("#51F1F2"), Offset = 1 } }; } gradientButton.BackgroundGradient = linearGradientBrush; } }
/// <summary> /// Gradient background changes based on selected chip. /// </summary> /// <param name="sender">chip</param> /// <param name="e">event arguments</param> private void Chip1_Clicked(object sender, EventArgs e) { int selectedIndex = 0; var selectedChip = sender as SfChip; var viewModel = (chipControl.BindingContext as GettingStartedViewModel); for (int i = 0; i < chipControl.Items.Count; i++) { var chip = chipControl.Items[i]; if (chip == selectedChip) { chip.BorderColor = Color.White; chip.BorderWidth = 2; selectedIndex = i; } else { chip.BorderColor = Color.Transparent; chip.BorderWidth = 0; } } chipSelectedIndex = selectedIndex; if (toggleButton.SelectedIndex == 0) { SfLinearGradientBrush brush = viewModel.LinearGradientBrushes[chipSelectedIndex]; brush.StartPoint = startPoint; brush.EndPoint = endPoint; viewModel.BackgroundGradient = brush; } else { viewModel.BackgroundGradient = viewModel.RadialGradientBrushes[chipSelectedIndex]; } }
async void ShowMessage() { messageLayout = new SfPopupLayout(); messageLayout.PopupView.ShowHeader = false; messageLayout.PopupView.ShowFooter = false; messageLayout.PopupView.ShowCloseButton = false; templateView = new DataTemplate(() => { Grid messageGrid = new Grid(); SfGradientView gradientView = new SfGradientView(); SfLinearGradientBrush linearGradientBrush = new SfLinearGradientBrush(); linearGradientBrush.GradientStops = new GradientStopCollection() { new SfGradientStop() { Color = Color.FromHex("#0048b9"), Offset = 0.0 }, new SfGradientStop() { Color = Color.FromHex("#00a8e8"), Offset = 1.0 }, }; gradientView.BackgroundBrush = linearGradientBrush; messageGrid.Children.Add(gradientView); StackLayout messageStack = new StackLayout(); Label mesageContent = new Label(); mesageContent.Text = "New Activity Added! +10 points!"; mesageContent.HorizontalTextAlignment = TextAlignment.Center; mesageContent.VerticalTextAlignment = TextAlignment.Center; mesageContent.FontAttributes = FontAttributes.Bold; mesageContent.FontSize = 15; mesageContent.Padding = 10; mesageContent.TextColor = Color.White; messageStack.Children.Add(mesageContent); messageGrid.Children.Add(messageStack); return(messageGrid); }); // Adding ContentTemplate of the SfPopupLayout messageLayout.PopupView.HeightRequest = 120; messageLayout.PopupView.ContentTemplate = templateView; messageLayout.PopupView.AnimationMode = AnimationMode.SlideOnBottom; await Task.Delay(2000); messageLayout.Show(); await Task.Delay(2000); messageLayout.PopupView.AnimationMode = AnimationMode.SlideOnTop; messageLayout.IsOpen = false; }