|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: Liquid Glass Effect for .NET MAUI Step Progress Bar | Syncfusion® |
| 4 | +description: Learn how to enable and customize the Liquid Glass Effect in the Syncfusion® .NET MAUI Step Progress Bar (SfStepProgressBar) control. |
| 5 | +platform: MAUI |
| 6 | +control: SfStepProgressBar |
| 7 | +documentation: ug |
| 8 | +--- |
| 9 | + |
| 10 | +# Liquid Glass Effect in .NET MAUI Step Progress Bar (SfStepProgressBar) |
| 11 | + |
| 12 | +The Liquid Glass Effect introduces a modern, translucent design with adaptive color tinting and light refraction, creating a sleek, glass like user experience that remains clear and accessible. This section explains how to enable and customize the effect in the Syncfusion® .NET MAUI Step Progress Bar (SfStepProgressBar) control. |
| 13 | + |
| 14 | +## Apply liquid glass effect |
| 15 | + |
| 16 | +Follow these steps to enable and configure the Liquid Glass Effect in the Step Progress Bar control: |
| 17 | + |
| 18 | +### Step 1: Wrap the control inside glass effect view |
| 19 | + |
| 20 | +To apply the Liquid Glass Effect to the Syncfusion® .NET MAUI [StepProgressBar](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.ProgressBar.SfStepProgressBar.html) control, wrap the control inside the `SfGlassEffectView` class. |
| 21 | + |
| 22 | +For more details, refer to the `Liquid Glass Getting Started documentation`. |
| 23 | + |
| 24 | +### Step 2: Customize the background |
| 25 | + |
| 26 | +To achieve a glass like background in the Step Progress Bar, set the `Background` property to `Transparent`. The background will then be treated as a tinted color, ensuring a consistent glass effect across the controls. |
| 27 | + |
| 28 | +The following code snippet demonstrates how to apply the Liquid Glass Effect to the [SfStepProgressBar](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.ProgressBar.SfStepProgressBar.html) control: |
| 29 | + |
| 30 | +{% tabs %} |
| 31 | +{% highlight xaml hl_lines="28 29 30 31 44" %} |
| 32 | + |
| 33 | +<Grid> |
| 34 | + <Grid.Background> |
| 35 | + <LinearGradientBrush StartPoint="0,0" |
| 36 | + EndPoint="0,1"> |
| 37 | + <GradientStop Color="#0F4C75" |
| 38 | + Offset="0.0" /> |
| 39 | + <GradientStop Color="#3282B8" |
| 40 | + Offset="0.5" /> |
| 41 | + <GradientStop Color="#1B262C" |
| 42 | + Offset="1.0" /> |
| 43 | + </LinearGradientBrush> |
| 44 | + </Grid.Background> |
| 45 | + <Grid.BindingContext> |
| 46 | + <local:ViewModel /> |
| 47 | + </Grid.BindingContext> |
| 48 | + <stepProgressBar:SfStepProgressBar x:Name="stepProgress" |
| 49 | + VerticalOptions="Center" |
| 50 | + HorizontalOptions="Center" |
| 51 | + Orientation="Horizontal" |
| 52 | + LabelSpacing="12" |
| 53 | + ActiveStepIndex="2" |
| 54 | + ActiveStepProgressValue="60" |
| 55 | + ProgressAnimationDuration="2500" |
| 56 | + ItemsSource="{Binding StepProgressItem}"> |
| 57 | + <stepProgressBar:SfStepProgressBar.StepTemplate> |
| 58 | + <DataTemplate> |
| 59 | + <Grid> |
| 60 | + <core:SfGlassEffectView WidthRequest="32" |
| 61 | + HeightRequest="32" |
| 62 | + CornerRadius="16" |
| 63 | + Background="#007AFF"> |
| 64 | + <Border Background="Transparent" |
| 65 | + Margin="0.5"> |
| 66 | + <Border.StrokeShape> |
| 67 | + <RoundRectangle CornerRadius="15" /> |
| 68 | + </Border.StrokeShape> |
| 69 | + <Label Text="" |
| 70 | + FontFamily="MauiMaterialAssets" |
| 71 | + HorizontalOptions="Center" |
| 72 | + VerticalOptions="Center" |
| 73 | + TextColor="White" |
| 74 | + FontSize="20" /> |
| 75 | + </Border> |
| 76 | + </core:SfGlassEffectView> |
| 77 | + </Grid> |
| 78 | + </DataTemplate> |
| 79 | + </stepProgressBar:SfStepProgressBar.StepTemplate> |
| 80 | + </stepProgressBar:SfStepProgressBar> |
| 81 | +</Grid> |
| 82 | + |
| 83 | +{% endhighlight %} |
| 84 | +{% highlight c# hl_lines="18 20 21 22 23 47 48" %} |
| 85 | + |
| 86 | +ViewModel viewModel = new ViewModel(); |
| 87 | +SfStepProgressBar stepProgressBar = new SfStepProgressBar() |
| 88 | +{ |
| 89 | + VerticalOptions = LayoutOptions.Center, |
| 90 | + HorizontalOptions = LayoutOptions.Center, |
| 91 | + Orientation = StepProgressBarOrientation.Horizontal, |
| 92 | + LabelSpacing = 12, |
| 93 | + ActiveStepIndex = 2, |
| 94 | + ActiveStepProgressValue = 60, |
| 95 | + ProgressAnimationDuration = 2500, |
| 96 | + ItemsSource = viewModel.StepProgressItem, |
| 97 | +}; |
| 98 | + |
| 99 | +var stepTemplate = new DataTemplate(() => |
| 100 | +{ |
| 101 | + var grid = new Grid(); |
| 102 | + |
| 103 | + var glassVeiew = new SfGlassEffectView |
| 104 | + { |
| 105 | + WidthRequest = 32, |
| 106 | + HeightRequest = 32, |
| 107 | + CornerRadius = 16, |
| 108 | + Background = Color.FromArgb("#007AFF") |
| 109 | + }; |
| 110 | + |
| 111 | + var border = new Border |
| 112 | + { |
| 113 | + Background = Colors.Transparent, |
| 114 | + Margin = new Thickness(0.5), |
| 115 | + StrokeShape = new RoundRectangle |
| 116 | + { |
| 117 | + CornerRadius = new CornerRadius(15) |
| 118 | + } |
| 119 | + }; |
| 120 | + |
| 121 | + var iconLabel = new Label |
| 122 | + { |
| 123 | + Text = "\ue70c", |
| 124 | + FontFamily = "MauiMaterialAssets", |
| 125 | + HorizontalOptions = LayoutOptions.Center, |
| 126 | + VerticalOptions = LayoutOptions.Center, |
| 127 | + TextColor = Colors.White, |
| 128 | + FontSize = 20 |
| 129 | + }; |
| 130 | + |
| 131 | + border.Content = iconLabel; |
| 132 | + glassVeiew.Content = border; |
| 133 | + grid.Add(glassVeiew); |
| 134 | + |
| 135 | + return grid; |
| 136 | +}); |
| 137 | + |
| 138 | +stepProgressBar.StepTemplate = stepTemplate; |
| 139 | +grid.Children.Add(stepProgressBar); |
| 140 | +this.Content = grid; |
| 141 | + |
| 142 | +{% endhighlight %} |
| 143 | +{% highlight c# tabtitle="ViewModel.cs" %} |
| 144 | + |
| 145 | +public class ViewModel |
| 146 | +{ |
| 147 | + /// <summary> |
| 148 | + /// The Step progress bar item collection. |
| 149 | + /// </summary> |
| 150 | + private ObservableCollection<StepProgressBarItem> stepProgressItem; |
| 151 | + |
| 152 | + /// <summary> |
| 153 | + /// The Step progress bar item collection. |
| 154 | + /// </summary> |
| 155 | + public ObservableCollection<StepProgressBarItem> StepProgressItem |
| 156 | + { |
| 157 | + get |
| 158 | + { |
| 159 | + return stepProgressItem; |
| 160 | + } |
| 161 | + set |
| 162 | + { |
| 163 | + stepProgressItem = value; |
| 164 | + } |
| 165 | + } |
| 166 | + |
| 167 | + public ViewModel() |
| 168 | + { |
| 169 | + stepProgressItem = new ObservableCollection<StepProgressBarItem>(); |
| 170 | + stepProgressItem.Add(new StepProgressBarItem() { PrimaryText = "Cart" }); |
| 171 | + stepProgressItem.Add(new StepProgressBarItem() { PrimaryText = "Address" }); |
| 172 | + stepProgressItem.Add(new StepProgressBarItem() { PrimaryText = "Delivery" }); |
| 173 | + stepProgressItem.Add(new StepProgressBarItem() { PrimaryText = "Ordered" }); |
| 174 | + } |
| 175 | +} |
| 176 | + |
| 177 | +{% endhighlight %} |
| 178 | +{% endtabs %} |
| 179 | + |
| 180 | +N> |
| 181 | +* Supported on `macOS 26 or higher` and `iOS 26 or higher`. |
| 182 | +* This feature is available only in `.NET 10.` |
0 commit comments