maui
maui copied to clipboard
[Bug] Picker Title Style Displaying Incorrectly
Description
- Picker Title is displayed with black font instead of the grey font that placeholders have.
- The Title color will also change with
TextColor
instead ofTitleColor
. - Setting the
ItemSource
to null or an emptry string will display the Title correctly.
From the Maui Picker Doc
Actual (black text)
Setting the TitleColor
to Red and TextColor
to Blue the Picker Title is displayed in Blue
<Picker x:Name="picker"
TextColor="Blue" TitleColor="Red" Title="Select a monkey">
<Picker.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Baboon</x:String>
<x:String>Capuchin Monkey</x:String>
<x:String>Blue Monkey</x:String>
</Picker.ItemsSource>
</Picker>
Steps to Reproduce
See the description/repo
Link to public reproduction project repository
https://github.com/Jake-Derrick/PickerTitleIssue
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS 16
Did you find any workaround?
No response
Relevant log output
No response
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.
Does anyone have a workaround till the fix hopefully makes it in a few decades?
Also having this issue. Only works if the ItemSource is empty and it's been focused and then unfocused. Is this fixed in .NET 8?
Still a issue in latest 8.0.7 MAUI. Placeholder color is not grey but normal black text
It looks like Picker.TextColor somehow overrides Picker.TitleColor, so the Picker.TitleColor has wrong color.
Here is a workaround:
Microsoft.Maui.Handlers.PickerHandler.Mapper.AppendToMapping("PickerMapper", (handler, view) => { if (view is Picker) { handler.PlatformView.TextColor = UIColor.PlaceholderText;
var item = ((Picker)view).SelectedItem;
if (item != null)
{
handler.PlatformView.TextColor = UIColor.Black;
}
else
{
handler.PlatformView.TextColor = UIColor.PlaceholderText;
}
((Picker)view).SelectedIndexChanged += (s, e) =>
{
var item = ((Picker)view).SelectedItem;
if (item != null)
{
handler.PlatformView.TextColor = UIColor.Black;
}
else
{
handler.PlatformView.TextColor = UIColor.PlaceholderText;
}
};
}
});