Bug 47168 - Colors used for Picker Title on WinRT 8.1 and WinPhone 8.1 RT cannot be set
Summary: Colors used for Picker Title on WinRT 8.1 and WinPhone 8.1 RT cannot be set
Status: RESOLVED NOT_ON_ROADMAP
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.4
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-11-17 12:29 UTC by John Hardman
Modified: 2017-06-22 01:28 UTC (History)
3 users (show)

Tags: WinRT 8.1 Picker Title Color ac
Is this bug a regression?: ---
Last known good build:


Attachments
Screenshot showing white on white Picker Title (40.26 KB, image/png)
2016-11-17 12:29 UTC, John Hardman
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_ON_ROADMAP

Description John Hardman 2016-11-17 12:29:22 UTC
Created attachment 18503 [details]
Screenshot showing white on white Picker Title

On WinRT 8.1 and WinPhone 8.1 RT, setting the BackgroundColor and TextColor for a Picker has no effect on the Picker Title. Instead, the Title text appears to always be white, with the background color seemingly transparent to show the BackgroundColor of the view beneath the Picker in the z-order. That means that if the BackgroundColor of the view beneath is White (which it typically will be if the app has a light theme), the Picker Title is not visible to the user (see attached screenshot).

Whilst it would be sensible to extend the list of properties on Picker to give more control over colors, in the short term, if the BackgroundColor of the view beneath the Picker in the z-order is going to show through, then it would be sensible to render the foreground/text color of the Title text on the Picker to a color that will show up against the BackgroundColor of the view beneath. A simple method of doing this would be to use the following (from https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Platform.WinRT/Extensions.cs):

        public static Windows.UI.Color GetIdealForegroundForBackgroundColor(Windows.UI.Color backgroundColor)
        {
            var nThreshold = 105;
            int bgLuminance = Convert.ToInt32(backgroundColor.R * 0.2 + backgroundColor.G * 0.7 + backgroundColor.B * 0.1);

            Windows.UI.Color foregroundColor = 255 - bgLuminance < nThreshold ? Colors.Black : Colors.White;
            return foregroundColor;
        }
Comment 1 John Hardman 2016-11-17 12:31:21 UTC
Here's the code I used to create the screenshot:

            Label pickerLabel = new Label { Text = "Picker" , TextColor = Color.Black, BackgroundColor = Color.White };
            Picker picker = new Picker
            {
                BackgroundColor = Color.Aqua,
                TextColor = Color.Lime,
                Title = "Picker title",
            };
            picker.Items.Add("alpha");
            picker.Items.Add("bravo");
            picker.Items.Add("charlie");
            picker.Items.Add("delta");
            picker.Items.Add("echo");
            picker.Items.Add("foxtrot");
            picker.Items.Add("golf");
            picker.Items.Add("hotel");
            picker.Items.Add("india");
            picker.Items.Add("juliet");
            picker.Items.Add("kilo");
            picker.Items.Add("lima");
            picker.Items.Add("mike");
            picker.Items.Add("november");
            picker.Items.Add("oscar");
            picker.Items.Add("papa");
            picker.Items.Add("quebec");
            picker.Items.Add("romeo");
            picker.Items.Add("sierra");
            picker.Items.Add("tango");
            picker.Items.Add("uniform");

            StackLayout vslOuterPage = new StackLayout
            {
                BackgroundColor = Color.White,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Margin = new Thickness(0, 0, 0, 0),
                Padding = new Thickness(0, 10, 0, 10),
                Spacing = 0,
                Children =
                {
                    entryLabel,
                    entry,
                    entryWithCompletedHandlerLabel,
                    entryWithCompletedHandler,
                    searchBarLabel,
                    searchBar,
                    passwordEntryLabel,
                    passwordEntry,
                    displayAlertLabel,
                    displayAlertButton,
                    pickerLabel, // this bit is relevant for this bug
                    picker // this bit is relevant for this bug
                }
            };

            this.BackgroundColor = Color.White;
            this.Padding = new Thickness(5, 0, 5, 0);
            this.BindingContext = viewModel;
            this.Title = "Xamarin views";
            this.Content = vslOuterPage;
Comment 2 John Hardman 2016-11-17 12:33:57 UTC
BTW - whilst looking into this, could somebody correct the text in the documentation at 
https://developer.xamarin.com/api/property/Xamarin.Forms.Picker.Title/
to change
"or not showed at all."
to
"or not shown at all."
please
Comment 3 John Hardman 2016-11-17 14:56:17 UTC
Note that on UWP, the Picker Title uses the TextColor specified for the Picker. Rather than the suggestion above, WinRT 8.1 and WinPhone 8.1 RT should probably do the same.
Comment 4 Paul DiPietro [MSFT] 2017-03-27 20:00:53 UTC
It should probably behave the same as UWP and would most likely require a template adjustment if I had to guess.
Comment 5 David Ortinau [MSFT] 2017-06-22 01:28:54 UTC
These targets are being deprecated and are no longer on the roadmap. Expect 3.0 to no longer target them.