Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

How to override ToolbarRenderer?

$
0
0

Is it possible to override ToolbarRenderer on a specific platform?

I tried even setting my custom class in internal Registar class (running the code after Forms.Init()), but it still doesn't work.

var coreAssembly = Assembly.GetAssembly(typeof(ToolbarItem));
var registrarType = coreAssembly.GetType("Xamarin.Forms.Registrar");
var registeredProp = registrarType.GetProperty("Registered", BindingFlags.NonPublic | BindingFlags.Static);

var registerer = registeredProp.GetValue(null);
var registerMethod = registerer.GetType().GetMethod("Register");

var toolbarType = coreAssembly.GetType("Xamarin.Forms.Toolbar");
registerMethod.Invoke(registerer, new object[] { toolbarType, typeof(CustomToolbarRenderer) });

Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>