kaolick
kaolick

Reputation: 4857

How to use native platform icons for ToolBarItems in Xamarin.Forms (programmatically)?

What I have:

I have a Xamarin.Forms app with a ToolBar (ActionBar on Android, Navigation Bar on iOS). Within the ToolBar I have a ToolBarItem to delete something.

What I want:

For the ToolBarItem mentioned above I want to use the native platform icons (f.e. a trash can).

My question:

What is the proper way to achieve this? It seems that the only way to do this is to add and load separate png-files as described here. For Android this is not such a big deal I can officially download the icon files from Google's developer page. For iOS this is not possible.

Upvotes: 3

Views: 1436

Answers (1)

Ian Mercer
Ian Mercer

Reputation: 39277

Currently this looks to be almost impossible to override. Looking at the source for ToolbarRenderer you can see the UpdateItems method. This assumes that all of the toolbar items are of type ToolbarItem and it does not invoke a custom renderer for them, instead calling through directly to an extension method that converts ToolbarItem values into UIBarButtonItems containing a UIImage.

Upvotes: 2

Related Questions