We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to include custom cropping aspect in toolbar?

Platform: Xamarin.Forms |
Control: SfImageEditor

SfImageEditor allows you to include custom cropping aspect in toolbar. Crop sub toolbar has inbuilt cropping aspect toolbar item such as Free, Original, Square, 3:1, 1:3, 3:2, 2:3, 4:3, 3:4, 5:4 ,4:5, 16:9 and 9:16. You can add custom cropping aspect toolbar item to existing toolbar item collection.


Step 1: Create image editor sample with all necessary assemblies.


Please refer the below link to create a simple SfImageEditor sample along with the ways to configure it.



Step 2: To add custom cropping aspect toolbar item to existing toolbar item collection as like below,


var toolbarItem = ((ImageEditor.ToolbarSettings.ToolbarItems[3]) as FooterToolbarItem).SubItems[0] as FooterToolbarItem;
            toolbarItem.SubItems.Add(new Syncfusion.SfImageEditor.XForms.ToolbarItem()
                Text = "5:7",
                Icon = ImageSource.FromResource("CustomCroppingSample.CropAspect.png")


Step 3: On Cliking custom toolbar item, ToolbarItemSelected event will be triggered. From this, you can get selected toolbar item as an argument.

Using ToggleCropping(5,7) method, cropping can be performed based on the ratio which is passed in the arguments as like below,


 editor.ToolbarSettings.ToolbarItemSelected += ToolbarSettings_ToolbarItemSelected;


   private void ToolbarSettings_ToolbarItemSelected(object sender, ToolbarItemSelectedEventArgs e)
            var item = e.ToolbarItem as Syncfusion.SfImageEditor.XForms.ToolbarItem;
            if (item.Text == "5:7")
                 editor.ToggleCropping(5, 7);


Sample Link:




Custom cropping using xamarin SfImageEditor

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile