DEV Community

Cover image for Add Effects Like a Pro Using .NET MAUI Effects View
Suresh Mohan for Syncfusion, Inc.

Posted on • Originally published at syncfusion.com on

Add Effects Like a Pro Using .NET MAUI Effects View

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.

Basic .NET MAUI Effects

Mobile apps like .NET MAUI commonly include basic effects, like ripple, rotation, and scaling. These kinds of animations make the app highly interactive.

.NET MAUI Effects View

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.

How to integrate .NET MAUI Effects View in your app

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();
  }

}
Enter fullscreen mode Exit fullscreen mode

Step 2: Then, add the Syncfusion.Maui.Core namespace using the following code.

xmlns:effectsView="clr-namespace:Syncfusion.Maui.Core;assembly=Syncfusion.Maui.Core"
Enter fullscreen mode Exit fullscreen mode

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>
Enter fullscreen mode Exit fullscreen mode

Adding .NET MAUI Effects View to Card UI

Adding .NET MAUI Effects View to Card UI

Effects

Now, let’s see the various effects supported by the .NET MAUI Effects View control.

Highlight effects

SfEffects.Highlight is a smooth transition on the background color of the Effects View control.

<effectsView:SfEffectsView TouchDownEffects="Highlight" HighlightBackground="#FF0000"/>
Enter fullscreen mode Exit fullscreen mode

Highlight Effects in .NET MAUI Effects View Control

Highlight Effects in .NET MAUI Effects View Control

Ripple

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"/>
Enter fullscreen mode Exit fullscreen mode

Ripple Effects in .NET MAUI Effects View Control

Ripple Effects in .NET MAUI Effects View Control

Rotation

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"/>
Enter fullscreen mode Exit fullscreen mode

Rotation Effects in .NET MAUI Effects View Control

Rotation Effects in .NET MAUI Effects View Control

Scale

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"/>
Enter fullscreen mode Exit fullscreen mode

Scale Effects in .NET MAUI Effects View Control

Scale Effects in .NET MAUI Effects View Control

Selection

SfEffects.Selection is a smooth color transition to indicate whether the Effects View state is selected or not.

<effectsView:SfEffectsView LongPressEffects="Selection" SelectionBackground="#FF0000"/>
Enter fullscreen mode Exit fullscreen mode

Selection Effects in .NET MAUI Effects View Control

Selection Effects in .NET MAUI Effects View Control

Valid combination of effects

Following are the valid combination of effects that can be applied in the .NET MAUI Effects View control:

  • Highlight and ripple
  • Highlight and selection
  • Ripple and selection
  • Highlight, ripple, and selection
  • Scale and selection

Possible interactions to show effects

Now, let’s see the different touch interaction features available to set effects in the .NET MAUI Effects View control.

Touch down

Use the TouchDownEffects property to render the effects with touch-down interaction.

<effectsView:SfEffectsView TouchDownEffects="Ripple"/>
Enter fullscreen mode Exit fullscreen mode

Long press

Use the LongPressEffects property to render the effects with long-press interaction.

<effectsView:SfEffectsView LongPressEffects="Ripple"/>
Enter fullscreen mode Exit fullscreen mode

Touch up

Use the TouchUpEffects property to render the effects with touch-up interaction.

<effectsView:SfEffectsView TouchUpEffects="Ripple"/>
Enter fullscreen mode Exit fullscreen mode

When and where effects are needed

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.

Conclusion

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!

Discussion (0)