Commands

RadImageEditorToolbar provides a ToolbarItem for creating a command.

  • CommandToolbarItem: Allows executing an arbitrary user-defined command from the toolbar. The CommandToolbarItem has the following properties:

    • Command(ICommand): Specifies the command to execute.
    • CommandParameter(object): Specifies a parameter to be passed to the command upon execution.

You could use the CommandToolbarItem when the ImageEditorToolbar AutoGenerateItems property is set to "False".

Example

Here is an example how the CommandToolbarItem could be used

<telerikImageEditor:RadImageEditorToolbar Grid.Row="1" ImageEditor="{x:Reference imageEditor}" AutoGenerateItems="False">
    <telerikImageEditor:CommandToolbarItem Text="Save" Tapped="OnSaveTapped" />
</telerikImageEditor:RadImageEditorToolbar>

On the Tapped event we are going to save the image on the device:

private async void OnSaveTapped(object sender, EventArgs e)
{
    var folderPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
    var filePath = Path.Combine(folderPath, "image.jpg");

    using (var fileStream = File.Create(filePath))
    {
        await this.imageEditor.SaveAsync(fileStream, ImageFormat.Jpeg, 0.9);
    }

    Application.Current.MainPage.DisplayAlert("Success!", "The Image is saved", "OK");
}

SDK Browser application contains a sample Commands example. You can find it in the ImageEditor/Features folder.

See Also

In this article
Not finding the help you need? Improve this article