dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.21k stars 1.74k forks source link

[Bug] Picker Title Style Displaying Incorrectly #15139

Open Jake-Derrick opened 1 year ago

Jake-Derrick commented 1 year ago

Description

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

ghost commented 1 year ago

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.

Mithgroth commented 10 months ago

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

adessables commented 9 months ago

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?

mnidhk commented 8 months ago

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

DeveloperLookBook commented 6 months ago

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

holesnap commented 6 months ago

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