Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mbmccormick/3993739 to your computer and use it in GitHub Desktop.
Save mbmccormick/3993739 to your computer and use it in GitHub Desktop.
Updates the CustomMessageBox control to account for the SystemTray opacity property, similar to how the color property is being handled. This is needed when using the CustomMessageBox control with a page (such as Panorama control) that has a transparent S
From ffc6d879979b1290818de3ea7eb5dcf1e1f208bc Mon Sep 17 00:00:00 2001
From: Matt McCormick <[email protected]>
Date: Thu, 1 Nov 2012 09:43:59 -0400
Subject: [PATCH] Updating CustomMessageBox control to handle SystemTray
opacity properly.
---
.../CustomMessageBox/CustomMessageBox.cs | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/Microsoft.Phone.Controls.Toolkit/CustomMessageBox/CustomMessageBox.cs b/Microsoft.Phone.Controls.Toolkit/CustomMessageBox/CustomMessageBox.cs
index e43f131..505248b 100644
--- a/Microsoft.Phone.Controls.Toolkit/CustomMessageBox/CustomMessageBox.cs
+++ b/Microsoft.Phone.Controls.Toolkit/CustomMessageBox/CustomMessageBox.cs
@@ -139,6 +139,11 @@ namespace Microsoft.Phone.Controls
private Color _systemTrayColor;
/// <summary>
+ /// The current opacity of the system tray.
+ /// </summary>
+ private double _systemTrayOpacity;
+
+ /// <summary>
/// Called when the message is being dismissing.
/// </summary>
public event EventHandler<DismissingEventArgs> Dismissing;
@@ -500,12 +505,15 @@ namespace Microsoft.Phone.Controls
_frame = Application.Current.RootVisual as PhoneApplicationFrame;
_page = _frame.Content as PhoneApplicationPage;
- // Change the color of the system tray if necessary.
+ // Change the color and opacity of the system tray if necessary.
if (SystemTray.IsVisible)
{
// Cache the original color of the system tray.
_systemTrayColor = SystemTray.BackgroundColor;
+ // Cache the original opacity of the system tray.
+ _systemTrayOpacity = SystemTray.Opacity;
+
// Change the color of the system tray to match the message box.
if (Background is SolidColorBrush)
{
@@ -515,6 +523,9 @@ namespace Microsoft.Phone.Controls
{
SystemTray.BackgroundColor = (Color)Application.Current.Resources["PhoneChromeColor"];
}
+
+ // Change the opacity of the system tray to match the message box.
+ SystemTray.Opacity = 1.0;
}
// Hide the application bar if necessary.
@@ -659,10 +670,11 @@ namespace Microsoft.Phone.Controls
if (restoreOriginalValues)
{
// Set the system tray back to its original
- // color if necessary.
+ // color and opacity if necessary.
if (SystemTray.IsVisible)
{
SystemTray.BackgroundColor = _systemTrayColor;
+ SystemTray.Opacity = _systemTrayOpacity;
}
// Bring the application bar if necessary.
--
1.7.11.msysgit.1
@anthonyzz
Copy link

This pathc works fine! I am very interested. I'd read some MessageBox Control C# tutorial weeks ago, sounds like the skills on JS MessageBox is quite different from the WinForms MessageBox Control.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment