From df67dff982d45e6fb8d69b549b8683ca26f2a202 Mon Sep 17 00:00:00 2001 From: Paul DiPietro Date: Mon, 19 Dec 2016 06:45:15 -0600 Subject: [PATCH] [UWP] Use toolbar foreground color on primary items (#640) --- .../Bugzilla44453.cs | 55 +++++++++++++++++++ ...rin.Forms.Controls.Issues.Shared.projitems | 1 + Xamarin.Forms.Platform.WinRT/Platform.cs | 9 ++- 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44453.cs diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44453.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44453.cs new file mode 100644 index 000000000..c1f64ac3a --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla44453.cs @@ -0,0 +1,55 @@ +using Xamarin.Forms.CustomAttributes; +using Xamarin.Forms.Internals; + +#if UITEST +using Xamarin.UITest; +using NUnit.Framework; +#endif + +// Apply the default category of "Issues" to all of the tests in this assembly +// We use this as a catch-all for tests which haven't been individually categorized +#if UITEST +[assembly: NUnit.Framework.Category("Issues")] +#endif + +namespace Xamarin.Forms.Controls.Issues +{ + [Preserve(AllMembers = true)] + [Issue(IssueTracker.Bugzilla, 44453, "[UWP] ToolbarItem Text hard to see when BarTextColor is light", PlatformAffected.WinRT)] + public class Bugzilla44453 : TestMasterDetailPage + { + protected override void Init() + { + var content = new ContentPage + { + Title = "UWPToolbarItemColor", + Content = new StackLayout + { + VerticalOptions = LayoutOptions.Center, + Children = + { + new Label + { + LineBreakMode = LineBreakMode.WordWrap, + HorizontalTextAlignment = TextAlignment.Center, + Text = "The toolbar secondary items should not have white text on a light background" + } + } + } + }; + + MasterBehavior = MasterBehavior.Popover; + Master = new ContentPage + { + Title = "Master" + }; + Detail = new NavigationPage(content) + { + BarBackgroundColor = Color.Green, + BarTextColor = Color.White + }; + + Detail.ToolbarItems.Add(new ToolbarItem("Test Secondary Item", null, delegate { }, ToolbarItemOrder.Secondary)); + } + } +} \ No newline at end of file diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems index 57f1cb835..a420489c8 100644 --- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems @@ -134,6 +134,7 @@ + diff --git a/Xamarin.Forms.Platform.WinRT/Platform.cs b/Xamarin.Forms.Platform.WinRT/Platform.cs index e9f6b95c9..2e30ac10a 100644 --- a/Xamarin.Forms.Platform.WinRT/Platform.cs +++ b/Xamarin.Forms.Platform.WinRT/Platform.cs @@ -296,13 +296,16 @@ namespace Xamarin.Forms.Platform.WinRT button.Command = new MenuItemCommand(item); button.DataContext = item; -#if WINDOWS_UWP - toolBarProvider?.BindForegroundColor(button); -#endif ToolbarItemOrder order = item.Order == ToolbarItemOrder.Default ? ToolbarItemOrder.Primary : item.Order; + if (order == ToolbarItemOrder.Primary) + { +#if WINDOWS_UWP + toolBarProvider?.BindForegroundColor(button); +#endif commandBar.PrimaryCommands.Add(button); + } else commandBar.SecondaryCommands.Add(button); }