Sometimes we need to use the entire screen surface, so you can’t display the system tray, however it is not pleasant for the user, he can’t see the time or see the network status, etc …
I have already proposed two solutions to this problem on this blog:
Today we will see a third way, used in particular by Internet Explorer.
Principle
When a user opens Internet Explorer, there is no system tray. However, by using the application, we realize that the time is displayed when you open the application menu bar (eg by pressing « … »).
We’ll try to reproduce this behavior.
detect the opening of the application bar
This is easy, you only need to register to the StateChanged event of the application bar:
ApplicationBar.StateChanged ApplicationBar_StateChanged += ApplicatioBarStateChange_DisplayTime;
void ApplicatioBarStateChange_DisplayTime(object sender, ApplicationBarStateChangedEventArgs e)
{
bool menuvisible = e.IsMenuVisible;
}
Show system tray
To display the system tray, you need simply to write the following statement:
SystemTray.IsVisible = true;
By combining the two previous source codes, we get the behavior we wanted:
ApplicationBar.StateChanged += ApplicationBar_StateChanged;
void ApplicatioBarStateChange_DisplayTime(object sender, ApplicationBarStateChangedEventArgs e)
{
SystemTray.IsVisible = e.IsMenuVisible;
}
And voila!
Some glitch!
Our application has the behavior we wanted, however, we note that the page shifts when the system tray is displayed.
To remove this, use a small hack, instead of displaying the system tray with a opacity of 100%, use an opacity of 99%, the visual effect is almost unchanged, but the system tray will now come over the content and will not shift.
<phone:PhoneApplicationPage x:Class="Wikipedia.BrowsePage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" .. shell:SystemTray.Opacity="0.99" >
You can, if you want, put a lower value for the opacity.
Conclusion
With a few lines of code, we were able to reproduce the behavior of Internet Explorer, your users will no longer have to leave your application to view network status or what time is it.

