New to Telerik UI for .NET MAUIStart a free 30-day trial

Migrating the ImageEditor from Xamarin to .NET MAUI

Telerik .NET MAUI ImageEditor control preserves the same API as Xamarin.Forms ImageEditor with a few changes and improvements listed in the tables below:

Migrating the Namespaces

ControlControl nameXAML NamespcaceC# Namespace
Xamarin ImageEditorRadImageEditorxmlns:telerikImageEditor="clr-namespace:Telerik.XamarinForms.ImageEditor;assembly=Telerik.XamarinForms.ImageEditor"using Telerik.XamarinForms.ImageEditor;
Xamarin ImageEditorToolbarRadImageEditorToolbarxmlns:telerikImageEditor="clr-namespace:Telerik.XamarinForms.ImageEditor;assembly=Telerik.XamarinForms.ImageEditor"using Telerik.XamarinForms.ImageEditor;
.NET MAUI ImageEditorRadImageEditorxmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"using Telerik.Maui.Controls;
.NET MAUI ImageEditorToolbarRadImageEditorToolbarxmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"using Telerik.Maui.Controls;

Modifying the API

When migrating the ImageEditor from Xamarin to .NET MAUI, consider the following differences in the API:

Xamarin ImageEditor.NET MAUI ImageEditor
N/Asupport for exporting images as Gif
N/Asupport for exporting images as Bmp
N/AUndoCommand
N/ARedoCommand
N/ARotateBackwardCommand
N/ASaturationInteractiveCommand
N/ABrightnessInteractiveCommand
N/ABlurInteractiveCommand
N/AContrastInteractiveCommand
N/AHueInteractiveCommand
N/ASharpenInteractiveCommand

When migrating the ImageEditorToolbar from Xamarin to .NET MAUI, consider the following differences in the API:

Xamarin ImageEditorToolbar.NET MAUI ImageEditorToolbar
IsMultiLine with true and false valuesOverflowMode with DropDown, Scroll and Wrap(multiline) values
N/AOverflowMenuButtonVisibility
OverflowButtonTemplateOverflowMenuButtonTemplate
OverflowButtonText, OverflowButtonTextColor and OverflowButtonFontFamilyOverflowMenuButtonStyle - Style the overflow button
TransformsToolbarItemImageEditorTransformationsToolbarItem
CropToolbarItem for mobile and desktopImageEditorCropToolbarItem
N/AImageEditorCropOptionsToolbarItem
ResizeToolbarItemImageEditorResizeOptionsToolbarItem
RotateLeftToolbarItemImageEditorRotateLeftToolbarItem
RotateRightToolbarItemImageEditorRotateRightToolbarItem
FlipHorizontalToolbarItemImageEditorFlipHorizontalToolbarItem
FlipVerticalToolbarItemImageEditorFlipVerticalToolbarItem
EffectsToolbarItem for mobile and desktopImageEditorFiltersToolbarItem for mobile
N/AImageEditorFilterOptionsToolbarItem for desktop
TransformsToolbarItemImageEditorTransformationsToolbarItem
HueToolbarItemImageEditorHueToolbarItem
SaturationToolbarItemImageEditorSaturationToolbarItem
BrightnessToolbarItemImageEditorBrightnessToolbarItem
ContrastToolbarItemImageEditorContrastToolbarItem
BlurToolbarItemImageEditorBlurToolbarItem
SharpenToolbarItemImageEditorSharpenToolbarItem
UndoToolbarItemImageEditorUndoToolbarItem
RedoToolbarItemImageEditorRedoToolbarItem
ResetToolbarItemImageEditorResetToolbarItem
ApplyToolbarItemImageEditorApplyToolbarItem
CancelToolbarItemImageEditorCancelToolbarItem
TemplateToolbarItemReview the toolbar items RadToolbar control provides
CommandToolbarItemReview the toolbar items RadToolbar control provides
ZoomToFitToolbarItemImageEditorZoomToFitToolbarItem
N/AImageEditorZoomInToolbarItem
N/AImageEditorZoomOutToolbarItem
N/AImageEditorZoomToolbarItem
N/AImageEditorZoomToOriginalToolbarItem

The code snippets below represent the Xamarin and .NET MAUI definitions of the ImageEditor and ImageEditorToolbar with all predefined toolbar items.

Definition in Xamarin:

C#
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition />
        <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <telerikImageEditor:RadImageEditor x:Name="imageEditor">
        <telerikImageEditor:RadImageEditor.Source>
            <OnPlatform x:TypeArguments="ImageSource" Default="cat4.jpeg">
                <On Platform="UWP">Assets\cat4.jpeg</On>
            </OnPlatform>
        </telerikImageEditor:RadImageEditor.Source>
    </telerikImageEditor:RadImageEditor>
    <telerikImageEditor:RadImageEditorToolbar Grid.Row="1" ImageEditor="{x:Reference imageEditor}" AutoGenerateItems="False">
        <telerikImageEditor:EffectsToolbarItem AutoGenerateItems="False">
            <telerikImageEditor:BackToolbarItem/>
            <telerikImageEditor:ContrastToolbarItem AutoGenerateItems="False">
                <telerikImageEditor:CancelToolbarItem HorizontalOptions="Start" />
                <telerikImageEditor:TemplateToolbarItem>
                    <telerikImageEditor:TemplateToolbarItem.Template>
                        <DataTemplate>
                            <Slider Maximum="2" Minimum="0" Value="{Binding Value}" />
                        </DataTemplate>
                    </telerikImageEditor:TemplateToolbarItem.Template>
                </telerikImageEditor:TemplateToolbarItem>
                <telerikImageEditor:ApplyToolbarItem HorizontalOptions="End" />
            </telerikImageEditor:ContrastToolbarItem>
        </telerikImageEditor:EffectsToolbarItem>
        <telerikImageEditor:CropToolbarItem/>
        <telerikImageEditor:RotateLeftToolbarItem/>
        <telerikImageEditor:RotateRightToolbarItem/>
        <telerikImageEditor:UndoToolbarItem/>
        <telerikImageEditor:RedoToolbarItem/>
    </telerikImageEditor:RadImageEditorToolbar>
</Grid>

Definition in MAUI:

xaml
<Grid RowDefinitions="Auto,*">
    <Grid RowDefinitions="Auto,Auto,60,Auto" ColumnDefinitions="*,*,*,*" ColumnSpacing="5" RowSpacing="5" Margin="0,0,0,10">
        <Button Text="Brightness" Grid.ColumnSpan="2" Command="{Binding BrightnessInteractiveCommand, Source={x:Reference imageEditor}}">
            <Button.CommandParameter>
                <telerik:BrightnessCommandContext Brightness="{Binding Value, Source={x:Reference brightness}, Mode=TwoWay}"/>
            </Button.CommandParameter>
        </Button>
        <Slider Grid.Column="2" Grid.ColumnSpan="2" Minimum="-50" Maximum="50" x:Name="brightness"/>
        <Button Text="Hue" Grid.Row="1" Grid.ColumnSpan="2"  Command="{Binding HueInteractiveCommand, Source={x:Reference imageEditor}}">
            <Button.CommandParameter>
                <telerik:HueCommandContext Hue="{Binding Value, Source={x:Reference hue}, Mode=TwoWay}" />
            </Button.CommandParameter>
        </Button>
        <Slider Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" Minimum="-100" Maximum="100" x:Name="hue" />
        <Button Grid.Row="2" Text="Interactive Crop" Grid.ColumnSpan="2" Command="{Binding CropInteractiveCommand, Source={x:Reference imageEditor}}" />
        <Button Grid.Row="2" Grid.Column="2" Text="Apply" Command="{Binding ApplyInteractiveCommand, Source={x:Reference imageEditor}}" />
        <Button Grid.Row="2" Grid.Column="3" Text="Cancel" Command="{Binding CancelInteractiveCommand, Source={x:Reference imageEditor}}"/>
        <Button Grid.Row="3" Text="Flip –" Command="{Binding FlipHorizontalCommand, Source={x:Reference imageEditor}}"/>
        <Button Grid.Row="3" Grid.Column="1" Text="Flip |" Command="{Binding FlipVerticalCommand, Source={x:Reference imageEditor}}" />
        <Button Grid.Row="3" Grid.Column="2" Text="Rotate &lt;" Command="{Binding RotateLeftCommand, Source={x:Reference imageEditor}}" />
        <Button Grid.Row="3" Grid.Column="3" Text="Rotate &gt;" Command="{Binding RotateRightCommand, Source={x:Reference imageEditor}}" />
    </Grid>
    <telerik:RadImageEditor x:Name="imageEditor" 
                            Grid.Row="1"
                            Source="https://raw.githubusercontent.com/telerik/maui-samples/main/Samples/ControlsSamples/Resources/Images/borderconfigurationavatar.png" />
</Grid>

See Also