maui icon indicating copy to clipboard operation
maui copied to clipboard

[Bug] Picker Title Style Displaying Incorrectly

Open Jake-Derrick opened this issue 1 year ago • 6 comments

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 of TitleColor.
  • Setting the ItemSource to null or an emptry string will display the Title correctly.

From the Maui Picker Doc image

Actual (black text) image

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>

image

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

Jake-Derrick avatar May 17 '23 16:05 Jake-Derrick

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.

ghost avatar May 17 '23 18:05 ghost

Does anyone have a workaround till the fix hopefully makes it in a few decades?

Mithgroth avatar Jan 02 '24 14:01 Mithgroth

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?

adessables avatar Jan 25 '24 08:01 adessables

Still a issue in latest 8.0.7 MAUI. Placeholder color is not grey but normal black text

mnidhk avatar Feb 22 '24 10:02 mnidhk

It looks like Picker.TextColor somehow overrides Picker.TitleColor, so the Picker.TitleColor has wrong color.

DeveloperLookBook avatar Apr 10 '24 21:04 DeveloperLookBook

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;
                }
            };
        }
    });

holesnap avatar Apr 13 '24 19:04 holesnap