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 get toolbar item and change icon using name in SfImageEditor?

Platform: Xamarin.Forms |
Control: SfImageEditor |
Published Date: September 26, 2018 |
Last Revised Date: June 23, 2021

By default, In SfImageEditor we can get toolbar items based on index value. We can also get toolbar items using name.

 

Step 1: Create SfImageEditor sample with all necessary assemblies.


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

https://help.syncfusion.com/xamarin/sfimageeditor/getting-started

 

Step 2: To get toolbar item’s you can use available toolbar item’s name in SfImageEditor.

 

Please refer the below link to get available toolbar item’s name in SfImageEditor.

 

https://help.syncfusion.com/xamarin/sfimageeditor/toolbarcustomization#name

 

Code Snippet:

 

private void Toolitem_Clicked(object sender, EventArgs e)
{
    ItemName = GetName.Text;
    ToolbarItem = editor.ToolbarSettings.ToolbarItems;
    var toolbarItem = GetToolItem(ToolbarItem);
    if (toolbarItem != null)
    {
        toolbarItem.Icon = ImageSource.FromResource("ImageEditor_GettingStarted.icon.png");
    }
}

 

private ImageEditor.ToolbarItem GetToolItem(ObservableCollection<ImageEditor.ToolbarItem> toolbarItem)
{
    foreach (var toolItem in toolbarItem)
    {
        if (ItemName != null)
        {
            if (toolItem.Name.ToLower().Equals(ItemName.ToLower()))
            {
                ImageEditorToolbarItem = toolItem;
                break;
            }
            else if (toolItem is ImageEditor.FooterToolbarItem)
            {
                var subitems = (toolItem as ImageEditor.FooterToolbarItem).SubItems.Count;
                if (subitems > 0)
                {
                    var toolabrItem = (toolItem as ImageEditor.FooterToolbarItem).SubItems;
                    GetToolItem(toolabrItem);
                }
            }
        }
    }
    return ImageEditorToolbarItem;
}

 

Sample link:

 

https://www.syncfusion.com/downloads/support/directtrac/general/ze/ImageEditor_GettingStarted1051249361.zip

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
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