Hi,
We are using TinyIoC for DI, and I need to inject a dependency into my Custom Renderers in order to get resources:
[assembly: ExportRenderer(typeof(Entry), typeof(CustomEntryRenderer))]
namespace MyNamespace.CustomRenderers
{
public class CustomEntryRenderer : EntryRenderer
{
private readonly IResourceManager _resourceManager;
//public CustomEntryRenderer()
//{
//}
public CustomEntryRenderer(IResourceManager resourceManager)
{
_resourceManager = resourceManager;
}
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
SetFont();
}
private void SetFont()
{
Control.Font = UIFont.FromName(_resourceManager.Get<string>("GlobalFont"), _resourceManager.Get<int>("TextBoxFontSize"));
Control.TextColor = UIColor.Red;
}
}
}
However, this code throws an exception:
System.MissingMethodException: Default constructor not found for type MyNamespace.CustomRenderers.CustomEntryRenderer
If I add a default constructor, my _resourceManager is of course null. If I remove the IoC constructor and hardcode the font and fontsize, everything works great.
Any ideas?
Thanks,
Peter.