1

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.

Riyas
  • 475
  • 1
  • 8
  • 27

2 Answers2

1

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

try below code

Device.BeginInvokeOnMainThread(() =>
{
  picker.BackgroundColor = Color.Red;
  picker.TextColor=Color.Pink;
});
Mayur Kerasiya
  • 206
  • 1
  • 9
  • No, I asked for Title color not text color. – Riyas Jan 31 '18 at 06:00
  • @Riyas can tell me which title color you want to change is it displayed in when picker opens ? or something else ? – Mayur Kerasiya Jan 31 '18 at 06:31
  • 1
    I used following code to change the title color temporarily , `Control.AttributedPlaceholder = new Foundation.NSAttributedString(Control.AttributedPlaceholder.Value, foregroundColor: Color.FromRgb(0,0,0).ToUIColor());` But i need to change the color dynamically, is there any override method for picker tapped or when focused, we can change the Titile color again as i given. – Riyas Jan 31 '18 at 09:49
  • Picker does not contain property for **placeholder color** and **title of picker is displayed as placeholder in native control** so you have done is correct and proper for changing placeholder color @Riyas – Mayur Kerasiya Jan 31 '18 at 09:59
  • and i need it to change title color again whenever i tap the picker, for that i need override method, is there any available in custom renderer ? – Riyas Feb 02 '18 at 08:43