Adding effects to an application (particularly in a mobile app) is an important part of building your app. Adding effects not only enhances the app’s appearance but also user interaction and experience.
Especially, when you are developing a cross-platform app like in .NET MAUI, you should apply good effects to your UI design. In this blog, I’ll show you how to use our Effects View control to do this.
Mobile apps like .NET MAUI commonly include basic effects, like ripple, rotation, and scaling. These kinds of animations make the app highly interactive.
At Syncfusion, we understand the need for and usage of this requirement and provide you with a control named .NET MAUI Effects View. It’s a container control that provides modern effects like ripple, selection, scaling, and rotation. You can render these effects using touch interactions, such as touch down, touch up, and long press, and also by calling the API.
You can easily integrate the control into your .NET MAUI app and it will take care of the effects based on your requirement and settings.
Syncfusion .NET MAUI controls are available on Nuget.org. To add the Effects View control to your project, first, open the NuGet package manager in Visual Studio. Search for Syncfusion.Maui.Core and then install it. Then, follow these steps:
Step 1: In the MauiProgram.cs file, register the handler for Syncfusion core.
public static class MauiProgram { public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); builder.ConfigureSyncfusionCore(); return builder.Build(); } }
Step 2: Then, add the Syncfusion.Maui.Core namespace using the following code.
xmlns:effectsView="clr-namespace:Syncfusion.Maui.Core;assembly=Syncfusion.Maui.Core"
Step 3: Finally, add the Syncfusion .NET MAUI Effects View as the parent of the element to which you need to add the effects. Here, I have added it to a card UI.
<effectsView:SfEffectsView> <Grid WidthRequest="200" HeightRequest="75" ColumnDefinitions="75,*"> <Image Source="Person.png"/> <VerticalStackLayout Grid.Column="1"> <Label Text="Laura Steffi" FontSize="18"/> <Label Text="Data Science Analyst" /> </VerticalStackLayout> </Grid> </effectsView:SfEffectsView>
Now, let’s see the various effects supported by the .NET MAUI Effects View control.
SfEffects.Highlight is a smooth transition on the background color of the Effects View control.
<effectsView:SfEffectsView TouchDownEffects="Highlight" HighlightBackground="#FF0000"/
The SfEffects.Ripple is an expandable circle. It is initially placed on the tapped location, and it grows till the whole layout is filled. The SfEffects.Ripple is rendered based on the InitialRippleFactor.
<effectsView:SfEffectsView TouchDownEffects="Ripple"/>
SfEffects.Rotation provides a circular movement to the Effects View control around the center based on the specified Angle.
<effectsView:SfEffectsView TouchDownEffects="Rotation" Angle="180"/>
SfEffects.Scale is a smooth transition on the size of the SfEffectsView.Content from its actual size to the size mentioned on the ScaleFactor in pixels.
<effectsView:SfEffectsView ScaleFactor="0.85" TouchDownEffects="None" TouchUpEffects="None" LongPressEffects="Scale"/>
SfEffects.Selection is a smooth color transition to indicate whether the Effects View state is selected or not.
<effectsView:SfEffectsView LongPressEffects="Selection" SelectionBackground="#FF0000"/>
Following are the valid combination of effects that can be applied in the .NET MAUI Effects View control:
Now, let’s see the different touch interaction features available to set effects in the .NET MAUI Effects View control.
Use the TouchDownEffects property to render the effects with touch-down interaction.
<effectsView:SfEffectsView TouchDownEffects="Ripple"/>
Use the LongPressEffects property to render the effects with long-press interaction.
<effectsView:SfEffectsView LongPressEffects="Ripple"/>
Use the TouchUpEffects property to render the effects with touch-up interaction.
<effectsView:SfEffectsView TouchUpEffects="Ripple"/>
Effects are needed on interactive elements like buttons, sliders, tab headers, switches, etc. These interactive elements generally show ripple effects on tapping and highlight effects on mouse hovering. Cross-platform apps like .NET MAUI will depend on mouse hover and tap interactions.
If you are creating an interactive Image control, then simply add those interactions into the .NET MAUI Effects View control. Don’t worry, the control will take care of the effects.
Note: For more details, refer to the Getting started with .NET MAUI Effects View documentation.
Thanks for reading! I hope you enjoyed this blog. Try out the modern effects available in our .NET MAUI Effects View control and leave your feedback in the comments section below!
For questions, you can contact us through our support forum, support portal, or feedback portal. As always, we are happy to assist you!