Clear all annotations (Text, Shapes, Paths, etc) from Image Editor

18 Dec 20211 minute to read

By invoking the ClearAnnotations method of SfImageEditor, you can clear all the annotations (Text, Shapes, Path, and CustomView) added in the image editor without resetting the other edits (Rotation, Flip, Crop, Effects, etc).

The following code sample demonstrates this.

  • XAML
  • <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <imageEditor:SfImageEditor x:Name="imageEditor"
                                   Source="{Binding Image}"/>
        <StackLayout Grid.Row="1"
                     Orientation="Horizontal">
            <Button x:Name="ClearAnnotations"
                    Text="ClearAnnotations"
                    Clicked="ClearAnnotations_Clicked"/>
        </StackLayout>
    </Grid>
  • C#
  • private void ClearAnnotations_Clicked(object sender, EventArgs e)
    {
        imageEditor.ClearAnnotations();
    }

    ClearAnnotations support in Xamarin.Forms ImageEditor