|
1 | 1 | --- |
2 | 2 | layout: post |
3 | | -title: Liquid Glass Support for .NET MAUI Autocomplete entry | Syncfusion® |
4 | | -description: Learn here about providing liquid glass support for Syncfusion® .NET MAUI Autocomplete (SfAutocomplete) control and more. |
| 3 | +title: Liquid Glass Effect for .NET MAUI Autocomplete | Syncfusion® |
| 4 | +description: Learn how to enable and customize the Liquid Glass Effect in the Syncfusion® .NET MAUI Autocomplete (SfAutocomplete) control. |
5 | 5 | platform: MAUI |
6 | 6 | control: SfAutocomplete |
7 | 7 | documentation: ug |
8 | 8 | --- |
9 | 9 |
|
10 | | -# Liquid Glass Support for .NET MAUI Autocomplete |
| 10 | +# Liquid Glass Effect in .NET MAUI Autocomplete (SfAutocomplete) |
11 | 11 |
|
12 | | -The [SfAutocomplete](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Inputs.SfAutocomplete.html) supports a `liquid glass` appearance by hosting the control inside the Syncfusion [SfGlassEffectView](). You can customize the effect using properties such as [EffectType](), [EnableShadowEffect](), and round the corners using [CornerRadius](). This approach improves visual depth and readability when SfAutocomplete is placed over images or colorful layouts. Additionally, the dropdown portion of SfAutocomplete applies the glass effect only when the [EnableLiquidGlassEffect]() property is set to true. |
| 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 Autocomplete (SfAutocomplete) control. |
13 | 13 |
|
14 | | -## Availability |
| 14 | +## Apply liquid glass effect |
15 | 15 |
|
16 | | -1. This feature is supported on .NET 10 or greater. |
17 | | -2. This feature is supported on mac or iOS 26 or greater. |
18 | | -3. On platforms or versions below these requirements, the control renders without the acrylic blur effect and falls back to a standard background. |
| 16 | +Follow these steps to enable and configure the Liquid Glass Effect in the Autocomplete control: |
19 | 17 |
|
20 | | -## Prerequisites |
| 18 | +### Step 1: Wrap the control inside glass effect view |
21 | 19 |
|
22 | | -- Add the Syncfusion.Maui.Core package (for SfGlassEffectView) and Syncfusion.Maui.Inputs (for SfAutocomplete). |
| 20 | +To apply the Liquid Glass Effect to Syncfusion® .NET MAUI `Autocomplete` control, wrap the control inside the `SfGlassEffectView` class. |
23 | 21 |
|
24 | | -XAML example Wrap the SfAutocomplete in an SfGlassEffectView, then enable the dropdown’s glass effect with `EnableLiquidGlassEffect`. |
| 22 | +For more details, refer to the `Liquid Glass Getting Started documentation`. |
| 23 | + |
| 24 | +### Step 2: Enable the liquid glass effect on Autocomplete |
| 25 | + |
| 26 | +Set the `EnableLiquidGlassEffect` property to `true` in the `SfAutocomplete` control to apply the Liquid Glass Effect. When enabled, the effect is also applied to its dependent controls and provides responsive interaction for a smooth and engaging user experience. |
| 27 | + |
| 28 | +### Step 3: Customize the background |
| 29 | + |
| 30 | +To achieve a glass like background in the Autocomplete, set the `Background` and `DropDownBackground` property to `Transparent`. The background will then be treated as a tinted color, ensuring a consistent glass effect across the controls. |
| 31 | + |
| 32 | +The following code snippet demonstrates how to apply the Liquid Glass Effect to the `SfAutocomplete` control: |
25 | 33 |
|
26 | 34 | {% tabs %} |
27 | | -{% highlight xaml hl_lines="19 22" %} |
28 | | - |
29 | | -<?xml version="1.0" encoding="utf-8" ?> |
30 | | -<ContentPage |
31 | | - xmlns="http://schemas.microsoft.com/dotnet/2021/maui" |
32 | | - xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" |
33 | | - xmlns:inputs="clr-namespace:Syncfusion.Maui.Inputs;assembly=Syncfusion.Maui.Inputs" |
34 | | - xmlns:core="clr-namespace:Syncfusion.Maui.Core;assembly=Syncfusion.Maui.Core" |
35 | | - x:Class="AcrylicAutocompleteBoxPage"> |
36 | | - |
37 | | - <Grid> |
38 | | - <!-- Background to make acrylic blur visible --> |
39 | | - <Image Source="wallpaper.jpg" Aspect="AspectFill" /> |
40 | | - <core:SfGlassEffectView |
41 | | - CornerRadius="20" |
42 | | - HeightRequest="40" |
43 | | - EffectType="Regular" |
44 | | - EnableShadowEffect="True"> |
45 | | - |
46 | | - <inputs:SfAutocomplete |
47 | | - EnableLiquidGlassEffect="True" |
48 | | - Background="Transparent" |
49 | | - ItemsSource="{Binding Employees}" |
50 | | - DisplayMemberPath="Name" |
51 | | - DropDownBackground="Transparent" |
52 | | - Placeholder="Select employee"/> |
53 | | - </core:SfGlassEffectView> |
54 | | - </Grid> |
55 | | -</ContentPage> |
| 35 | +{% highlight xaml tabtitle="MainPage.xaml" hl_lines="11" %} |
| 36 | + |
| 37 | +<Grid BackgroundColor="Transparent"> |
| 38 | +<Image Source="Wallpaper.png" Aspect="AspectFill"> |
| 39 | + <core:SfGlassEffectView EffectType="Regular" |
| 40 | + CornerRadius="20"> |
| 41 | + <Autocomplete:SfAutocomplete x:Name="Autocomplete" |
| 42 | + Background="Transparent" |
| 43 | + HeightRequest="40" |
| 44 | + WidthRequest="300" |
| 45 | + ItemSource="{Binding Names}" |
| 46 | + DropDownBackground="Transparent" |
| 47 | + EnableLiquidGlassEffect="True"> |
| 48 | + </Autocomplete:SfAutocomplete> |
| 49 | + </core:SfGlassEffectView> |
| 50 | +</Grid> |
56 | 51 |
|
57 | 52 | {% endhighlight %} |
58 | | -{% highlight c# hl_lines="14 17" %} |
| 53 | +{% highlight c# tabtitle="MainPage.xaml.cs" hl_lines="29" %} |
59 | 54 |
|
60 | 55 | using Syncfusion.Maui.Core; |
61 | 56 | using Syncfusion.Maui.Inputs; |
62 | 57 |
|
63 | | -var glassEffects = new SfGlassEffectView |
64 | | -{ |
65 | | - CornerRadius=20, |
66 | | - HeightRequest=40, |
67 | | - EffectType=LiquidGlassEffectType.Regular, |
68 | | - EnableShadowEffect=True |
69 | | -}; |
70 | | - |
71 | | -var Autocomplete = new SfAutocomplete |
72 | | -{ |
73 | | - EnableLiquidGlassEffect = true, // Dropdown glass effect |
74 | | - ItemsSource = viewModel.Employees, |
75 | | - DisplayMemberPath = "Name", |
76 | | - Background=Colors.Transparent, |
77 | | - DropDownBackground= Colors.Transparent, |
78 | | - Placeholder = "Select employee", |
79 | | -}; |
80 | | - |
81 | | -glassEffects.Content = Autocomplete; |
| 58 | + var grid = new Grid |
| 59 | + { |
| 60 | + BackgroundColor = Colors.Transparent |
| 61 | + }; |
| 62 | + |
| 63 | + var image = new Image |
| 64 | + { |
| 65 | + Source = "Wallpaper.png", |
| 66 | + Aspect = Aspect.AspectFill |
| 67 | + }; |
| 68 | + grid.Children.Add(image); |
| 69 | + |
| 70 | + var glass = new SfGlassEffectView |
| 71 | + { |
| 72 | + EffectType = LiquidGlassEffectType.Regular, |
| 73 | + CornerRadius = 20 |
| 74 | + }; |
| 75 | + |
| 76 | + var autocomplete = new SfAutocomplete |
| 77 | + { |
| 78 | + Background = Colors.Transparent, |
| 79 | + HeightRequest = 40, |
| 80 | + WidthRequest = 300, |
| 81 | + DropDownBackground = Colors.Transparent, |
| 82 | + ItemSource = new List<string>{"Jacob", "Will", "Noah", "Dustin"}, |
| 83 | + EnableLiquidGlassEffect = true |
| 84 | + }; |
| 85 | + |
| 86 | + glass.Content = autocomplete; |
| 87 | + grid.Children.Add(glass); |
| 88 | + this.Content = grid; |
82 | 89 |
|
83 | 90 | {% endhighlight %} |
84 | 91 | {% endtabs %} |
85 | 92 |
|
86 | | - |
87 | 93 | The following screenshot illustrates SfAutocomplete within an acrylic container, with the dropdown using the glass effect. |
88 | 94 |
|
89 | | - |
| 95 | + |
| 96 | + |
| 97 | +N> |
| 98 | +This feature is supported only on .NET 10 along with iOS 26 and macOS 26 |
0 commit comments