.NET MAUI ImageEditor Commands
This article shows all the commands available in the ImageEditor for .NET MAUI.
All built-in and interactive commands
ImageEditor for .NET MAUI provides commands for programmatically editing the image without the usage of the ImageEditorToolbar
. The available commands are:
-
CropCommand
(ICommand
)—Crop the image. TheCropCommandContext
object is passed as a parameter to theCropCommand
. TheCropCommandContext
has the following properties:-
Geometry
(of typeTelerik.Maui.Controls.RadGeometry
)—Specifies the geometry of the crop selection. -
Bounds
(of typeRectangle
)—Used to get the current crop bounding rectangle.
-
CropInteractiveCommand
(ICommand
)—Initiates the crop action.-
ResizeCommand
—For image resizing. TheResizeCommandContext
object is passed as a parameter to theResizeCommand
. TheResizeCommandContext
has the following property:-
Size
(of typeMicrosoft.Maui.Graphics.Size
)—Specifies the size which will be used to resize the image.
-
ResizeInteractiveCommand
—For image resizing.-
BlurCommand
—Applies blur to the image. TheBlurCommandContext
object is passed as a parameter to theBlurCommand
. TheBlurCommandContext
has the following property:-
Blur
(int
)—Specifies the blur value.
-
BlurInteractiveCommand
(ICommand
)—Initiates the blur action.-
BrightnessCommand
(ICommand
)—Changes the brightness of the image. TheBrightnessCommandContext
object is passed as a parameter to theBrightnessCommand
. TheBrightnessCommandContext
has the following property:-
Brightness
(double
)—Specifies the brightness value.
-
BrightnessInteractiveCommand
(ICommand
)—Initiates the brightness action.-
ContrastCommand
(ICommand
)—Changes the image contrast. TheContrastCommandContext
object is passed as a parameter to theContrastCommand
. TheContrastCommandContext
has the following property:-
Contrast
(double
)—Specifies the contrast value.
-
ContrastInteractiveCommand
(ICommand
)—Initiates the contrast action.-
HueCommand
(ICommand
)—Changes the image hue. TheHueCommandContext
object is passed as a parameter to theHueCommand
. TheHueCommandContext
has the following property:-
Hue
(double
)—Specifies the hue value.
-
HueInteractiveCommand
(ICommand
)—Initiates the hue action.-
SaturationCommand
(ICommand
):—Changes the image saturation. TheSaturationCommandContext
object is passed as a parameter to theSaturationCommand
. TheSaturationCommandContext
has the following property:-
Saturation
(double
)—Specifies the saturation value.
-
SaturationInteractiveCommand
(ICommand
)—Initiates the saturation action.-
SharpenCommand
(ICommand
)—Changes the image sharpness. TheSaturationCommandContext
object is passed as a parameter to theSharpenCommand
. TheSharpenCommandContext
has the following property:-
Sharpen
(int
)—Specifies the sharpen value.
-
SharpenInteractiveCommand
(ICommand
)—Initiates the sharpen action.FlipHorizontalCommand
(ICommand
)—Flips the image horizontally.FlipVerticalCommand
(ICommand
)—Flips the image vertically.FilterCommand
(ICommand
)—Applies a composite filter to the image.FilterInteractiveCommand
(ICommand
)—Initiates the composite filter action of the image.
Commands which cancel/apply the changes made in interactive commands:
CancelInteractiveCommand
—Cancels the changes done in interactive command such asTelerik.Maui.Controls.RadImageEditor.CropInteractiveCommand
.ApplyInteractiveCommand
—Applies the changes done in interactive command such asTelerik.Maui.Controls.RadImageEditor.CropInteractiveCommand
.
When using the Interactive Commands you can apply the changes using
ApplyInteractiveCommand
and cancel the changes usingCancelInteractiveCommand
.
ZoomToFitCommand
(ICommand
)—Gets the command which zooms the image to fit the available screen space.RotateLeftCommand
(ICommand
)—For image rotation 90 degree to the left.RotateRightCommand
—For image rotation 90 degree to the right.UndoCommand
(ICommand
)—Gets the command for the undo action.RedoCommand
(ICommand
)—Gets the command for the redo action.ResetCommnad
(ICommand
)—Reset all changes applied to the image.RotateBackwardCommand
(ICommand
)—Rotates the image backwards.
Commands Inherited from the Toolbar control
-
NavigateCommand
(ICommand
)—Gets a command for navigating to the next level of the toolbar hierarchy. The command accepts a collection ofTelerik.Maui.Controls.ToolbarItems
as a parameter. -
NavigateBackCommand
(ICommand
)—Gets a command for navigating back to the previous level of the toolbar hierarchy. The previousTelerik.Maui.Controls.ToolbarItems
stored in the navigation stack from the last invocation of theTelerik.Maui.Controls.RadToolbar.NavigateCommand
are restored in the toolbar. -
ScrollForwardCommand
(ICommand
)—Gets a command for scrolling the contents of the toolbar in a forward direction. This command is applicable when theRadToolbar.OverflowMode
is set toScroll
. -
ScrollBackwardCommand
(ICommand
)—Gets a command for scrolling the contents of the toolbar in backward direction. This command is applicable when theRadToolbar.OverflowMode
is set to Scroll.
Example with Interactive Commands and Rotate Left and Right
1. The ImageEditor definition in XAML with Brightness, Hue, Crop, Flip, Rotate, Cancel and Accept commands:
<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 <" Command="{Binding RotateLeftCommand, Source={x:Reference imageEditor}}" />
<Button Grid.Row="3" Grid.Column="3" Text="Rotate >" 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>
2. Add the following namespace:
xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
For the runnable ImageEditor Commands example, see the SDKBrowser Demo Application and go to ImageEditor > Features.