Events in the .NET MAUI Image Editor (SfImageEditor)

21 Jul 20263 minutes to read

The SfImageEditor supports the ImageLoaded and AnnotationSelected events to interact with the .NET MAUI Image Editor.

Image loaded event

The ImageLoaded event occurs after the image is loaded. Use this event to add shapes or text over an image, or to crop an image during initial loading.

<imageEditor:SfImageEditor x:Name="imageEditor"
                           Source="image.png"
                           ImageLoaded="OnImageLoaded" />
using Syncfusion.Maui.ImageEditor;

private void OnImageLoaded(object sender, EventArgs e)
{
    this.imageEditor.Rotate();
}

NOTE

View sample in GitHub

Annotations deserialized event

The AnnotationsDeserialized event occurs when the annotations are deserialized onto the image.

NOTE

Serialization and deserialization are not applicable for custom annotation views.

<imageEditor:SfImageEditor x:Name="imageEditor"
                           Source="image.png"
                           AnnotationsDeserialized="OnAnnotationsDeserialized" />
using Syncfusion.Maui.ImageEditor;

private async void OnAnnotationsDeserialized(object sender, EventArgs e)
{
    await DisplayAlert("", "Annotations are deserialized", "Ok");
}

Annotation selected event

The AnnotationSelected event occurs when an annotation is selected.

NOTE

This event is common for Shape and Text annotations.

<imageEditor:SfImageEditor Source="image.png"
                           AnnotationSelected="OnAnnotationSelected" />
using Microsoft.Maui.Graphics;
using Syncfusion.Maui.ImageEditor;

private void OnAnnotationSelected(object sender, AnnotationSelectedEventArgs e)
{
    if (e.AnnotationSettings is ImageEditorShapeSettings shapeSettings)
    {
        shapeSettings.Color = Colors.Black;
    }
}

Browse image event

The BrowseImage event occurs when the browse icon in the toolbar is clicked while browsing the image source.

Cancel

Restrict the default image browse picker from opening by setting the Cancel property to true.

<imageEditor:SfImageEditor Source="image.png"
                           BrowseImage="OnImageBrowse" />
using System.ComponentModel;
using Syncfusion.Maui.ImageEditor;

private void OnImageBrowse(object sender, CancelEventArgs e)
{
    e.Cancel = true;
}