1

How do I create a platform-specific custom renderer within a Xamarin.Forms class library?

I'm creating a Xamarin Forms class library that allows me to expand a picker's list with a tap anywhere on the control. That means I need to open the picker's list programmatically within the control's Tapped event handler.

This is trivial in the Android and iOS picker implementations - just a call to the picker's .Focus() method. However, the .Focus() method of the UWP's picker doesn't respond the same way - mainly because UWP must also handle mouse events, not just touch events.

Conceptually no problem, though, since I should be able to create a custom renderer for UWP to set the combobox's .DropDown property within the Tapped even handler.

Except...I'm not sure how to create a platform-specific custom renderer within a class library, since - unlike a normal Xamarin.Forms project - there are no platform-specific projects in which to implement custom renderers. Unfortunately, I haven't been able to find information anywhere about how to do this.

FactoryOptimizr
  • 306
  • 3
  • 13
  • You would do this in a UWP library, not a cross-platform one. This is why most XF Plugins contain a PCL that contains common abstractions, as well as a separate library for each platform that contains the actual implementation for that platform. – Jason May 27 '18 at 19:13
  • Thanks, @Jason. Would you be able to post a simple example or direct me to an example online? – FactoryOptimizr May 31 '18 at 05:21

0 Answers0