Using a custom renderer in PCL library

I want to use my custom renderer inside a PCL. Is it possible? Or can I initialize my custom renderer inside this PCL?

Upvotes: 1

Views: 233

Answers (2)

Finally, I've found a solution. I've just created a class in my PCL and used it in XAML, let's say:

public class MyHelperEntry : Entry { public MyHelperEntry() { } }

that inherits Entry class. And in an App, where I use this PCL, I've created a class, that inherits MyHelperEntry:

public CustomHelperEntry : MyHelperEntry { public CustomHelperEntry() { } }

and used this CustomHelperEntry as a custom renderer.

Upvotes: 0

Diego Rafael Souza
Diego Rafael Souza

Reputation: 5314

No and No.

What you use in PCL is - let's say - component and it's abstraction. The 'materialization' (or not) of the component will be made by custom renders on each platform.

I can't see a reason to use it on a platform-independent implementation once it can be shown (or to behaves) differently on each one.

Custom Renderers let developers override this process to customize the appearance and behavior of Xamarin.Forms controls on each platform.

https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/custom-renderer/

Maybe with a real case, we can suggest another solution.

Upvotes: 1

Related Questions