[WP8] CustomMessageBox dismissal no longer causes black SystemTray
authorPaul DiPietro <paul.dipietro@me.com>
Mon, 28 Mar 2016 04:48:21 +0000 (00:48 -0400)
committerPaul DiPietro <paul.dipietro@me.com>
Mon, 28 Mar 2016 04:57:30 +0000 (00:57 -0400)
The CustomMessageBox was having an interaction with WP8 where its
dismissal was changing the SystemTray's background color to black. It
appears that the SystemTray's background color was never set, despite
its appearing white prior to the use of a CustomMessageBox.

Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla25234.cs [new file with mode: 0644]
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
Xamarin.Forms.Platform.WP8/Platform.cs

diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla25234.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla25234.cs
new file mode 100644 (file)
index 0000000..b29cbd3
--- /dev/null
@@ -0,0 +1,35 @@
+using System;
+
+using Xamarin.Forms.CustomAttributes;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+       [Preserve(AllMembers = true)]
+       [Issue(IssueTracker.Bugzilla, 25234, "Use of CustomMessageBox resets SystemTray BackgroundColor to black", PlatformAffected.WinPhone)]
+       public class Bugzilla25234 : TestContentPage
+       {
+               protected override void Init()
+               {
+                       Content = new StackLayout
+                       {
+                               Children =
+                               {
+                                       new Button
+                                       {
+                                               Text = "Click for Alert",
+                                               Command = new Command(() =>
+                                               {
+                                                       DisplayAlert("Display Alert",
+                                                               "If the theme is set to light on WP8, the status bar should return to the white color when closed", "OK");
+                                               })
+                                       }
+                               }
+                       };
+               }
+       }
+}
index 81a6c2e..06a89b6 100644 (file)
@@ -19,6 +19,7 @@
     </Compile>
     <Compile Include="$(MSBuildThisFileDirectory)Bugzilla22401.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Bugzilla24769.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)Bugzilla25234.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Bugzilla25662.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Bugzilla26501.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Bugzilla26868.cs" />
index 363c6b8..4626542 100644 (file)
@@ -42,6 +42,7 @@ namespace Xamarin.Forms.Platform.WinPhone
 
                        _renderer = new Canvas();
                        _renderer.SizeChanged += RendererSizeChanged;
+                       _renderer.Loaded += (sender, args) => UpdateSystemTray();
 
                        _tracker.CollectionChanged += (sender, args) => UpdateToolbarItems();
 
@@ -483,6 +484,15 @@ namespace Xamarin.Forms.Platform.WinPhone
                        }
                }
 
+               void UpdateSystemTray()
+               {
+                       var lightThemeVisibility = (Visibility)System.Windows.Application.Current.Resources["PhoneLightThemeVisibility"];
+                       if (lightThemeVisibility == Visibility.Visible && SystemTray.BackgroundColor == System.Windows.Media.Color.FromArgb(0, 0, 0, 0))
+                       {
+                               SystemTray.BackgroundColor = System.Windows.Media.Color.FromArgb(1, 255, 255, 255);
+                       }
+               }
+
                void UpdateToolbarItems()
                {
                        if (_page.ApplicationBar == null)