If you have always wanted to give the title of your Picker control a color, this is your lucky day! A pull request is merged that will let you do just that. It introduces a new property on the Picker control that allows you to set the TitleColor. In this post, I will show you how to use it and what it does.
The Picker Control
Before we get to the new feature, let’s have a closer look at the Picker control itself. Because actually there is no such thing as a Picker control. The Xamarin.Forms Picker control is actually a combination of an Entry control that triggers the native way of picking a value from a list. Depending on the actual platforms the concrete implementation varies a little bit.
You can see an example of what this looks like on iOS and Android in the image underneath.

Since the first implementation of the
What was not implemented was the ability to style this title. That is why an issue was opened on the Xamarin
Introducing the new TitleColor property
If you have read earlier posts about contributions to Xamarin.Forms, you might know by now that implementing a new feature is usually a matter of building it in the abstract layer and then in the platform specific renderers.
In the abstract layer, in this case, the Picker control, we add a new property that the developer can use to let us know what color to use. Now that we have this value, we can go into the renderers to take that color and render it in a way that would make sense on that platform. In the image underneath, you can see what that looks like on the different supported platforms which are iOS, Android and UWP right now.

Android Dialog Title
When I opened the PR, it got approved pretty fast. But also Paymicro “challenged” me and said that it would be awesome if the dialog on Android would have the same title color. When you open a picker on Android, a new dialog is shown with all the options the user can pick from. This dialog also has a title.
It took a bit of effort to get it right. The dialog is creating using
Then, at some point I got the idea to make a spannable string, color that and load that through the regular method that just takes in a string for the title. And whatdayaknow! It worked 🙂
The end result is in the image underneath.

Summary
Although the feature might be a small one, I still hope you find it useful. I don’t think it is clear yet in which Xamarin
Let me know if you are using this or anything else I implemented, or maybe you have a few ideas of your own. I’m always open to chat! Thank you for reading!
1 thought on “Adding TitleColor to Your Picker in Xamarin.Forms”
Comments are closed.