1
votes

I am looking for "Highlight the Picker with Background color whenever it is clicked" and also "Title Color"

And when i click other picker the previous picker has to be change to default color, and current clicked picker has to be change color.

I tried with PickerName.BackgroundColor property in code behind, but its not working properly, sometimes its not changing. Is there any other way or how to achieve this using custom renderer or anything?. Thanks in advance.

2
have you tried changing background color on Main Thread ?Mayur Kerasiya
yeah, its working with that and also Focused evnent, but is this the correct way to do that? and Title Text color is not changed at all.Riyas
UI always update on main thread so it is the correct way for updating background color.Mayur Kerasiya

2 Answers

1
votes

We can change BackgroundColor in SelectedIndexChanged event in PCL.

picker.SelectedIndexChanged += (sender, args) =>
 {
     picker.BackgroundColor=Color.Red;
 };

(or)

We can achieve this through CustomRenderer.

Example: https://forums.xamarin.com/discussion/18563/custom-renderer-for-picker

Xamarin.iOS

http://www.c-sharpcorner.com/article/uipickerview-in-xamarin-ios/

Find Override method for Picker Selection in Xamarin.iOS and put that override method in CustomRenderer and in that change the background color

1
votes

try below code

Device.BeginInvokeOnMainThread(() =>
{
  picker.BackgroundColor = Color.Red;
  picker.TextColor=Color.Pink;
});