I'm new to Xamarin.Forms programming. Would like to customize/change the way the Picker
In the picture: -Button with the text 'Select', when clicked calls picker.Focus() -Picker with both black background and text colors behind the select button -Empty ListView -The picker options wheel pane, pops up when a picker is 'Focused'
Picker implementation code:
Picker picker = new Picker
{
HorizontalOptions = LayoutOptions.Start,
VerticalOptions = LayoutOptions.Center,
WidthRequest = 73,
HeightRequest = 25,
BackgroundColor = Color.Black,
TextColor = Color.Black
};
List<string> myList = new List<string>();
myList.Add("OPTIONS 1");
myList.Add("OPTIONS 2");
myList.Add("OPTIONS 3");
myList.Add("OPTIONS 4");
myList.Add("OPTIONS 5");
foreach (string str in myList)
{
picker.Items.Add(str);
}
Code customizes the 'box' that a user clicks to bring the picker options wheel pane into view, but doesn't (or at least appear to) offer any options for customizing the picker pane.
How to place the picker wheel pop-up pane inside of the ListView? How to change font size of the options inside the picker wheel and change the height of the pane displaying the options?
tl;dr - How to change picker pane height, item font size, pane placement?
This is as far as I've gotten...
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using AppName.iOS;
using AppName;
[assembly: ExportRenderer(typeof(MyPicker), typeof(MyPickerRenderer))]
namespace AppName.iOS
{
public class MyPickerRenderer : PickerRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Picker> e)
{
base.OnElementChanged(e);
if (e.OldElement != null)
{
// Unsubscribe from event handlers and cleanup any resources
}
if (e.NewElement != null)
{
// Configure the native control and subscribe to event handlers
}
}
}
}