Articles in this section

How to change the opacity of the toolbar custom icons in .NET MAUI SfImageEditor?

In the .NET MAUI SfImageEditor control, you can enhance user interactions by adjusting the opacity of the custom icons based on enabled or disabled state. This article explains how to achieve this for the undo and redo custom icon views:

Step 1: Retrieve the Undo and Redo Items

First, retrieve the Undo and Redo items from the ImageEditorToolbar:

C#

ImageEditorToolbar headerToolbar = imageEditor.Toolbars[0];
ImageEditorToolbarGroupItem saveGroup = (ImageEditorToolbarGroupItem)headerToolbar.ToolbarItems[0];
ImageEditorToolbarItem undoItem = saveGroup.Items.FirstOrDefault(i => i.Name == "Undo");
ImageEditorToolbarItem redoItem = saveGroup.Items.FirstOrDefault(i => i.Name == "Redo");

Step 2: Customize the Undo and Redo Icons

Customize the Undo and Redo icons by setting their image source, and then set the opacity based on the IsEnabled property in the PropertyChanged event of the icons:

C#

if (undoItem != null) 
{
   Image undoImage = new Image();
   undoImage.Source = ImageSource.FromFile("undoicon.png");
   undoItem.View = undoImage;
   undoImage.PropertyChanged += (sender, e) =>
   {
       if (e.PropertyName == VisualElement.IsEnabledProperty.PropertyName)
       {
           double opacity = undoImage.IsEnabled ? 1.0 : 0.5;
           undoImage.Opacity = opacity;
       }
   };
}

if (redoItem != null)
{
   Image redoImage = new Image();
   redoImage.Source = ImageSource.FromFile("redoicon.png");
   redoItem.View = redoImage;
   redoImage.PropertyChanged += (sender, e) =>
   {
       if (e.PropertyName == VisualElement.IsEnabledProperty.PropertyName)
       {
           double opacity = redoImage.IsEnabled ? 1.0 : 0.5;
           redoImage.Opacity = opacity;
       }
   };
}

In the above code, the opacity of the icons is set to 1.0 when the IsEnabled property is true, and 0.5 when it is false.

This approach allows you to dynamically adjust the opacity of custom Undo and Redo Icons in the .NET MAUI SfImageEditor control.

Output

CustomIconsOpacity.gif

View the sample on GitHub.

Conclusion

I hope you enjoyed learning how to change the opacity of the custom undo and redo icons in the .NET MAUI SfImageEditor.

You can refer to our .NET MAUI ImageEditor’s feature tour page to learn about its other groundbreaking feature representations. You can explore our .NET MAUI ImageEditor documentation to understand how to present and manipulate data.

For current customers, you can check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our .NET MAUI ImageEditor and other .NET MAUI components.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied