post icon

Silverlight Tip of the Day #31 – Pinning Full Screen Mode

Full screen can be toggled on and off via a user command such as a button click by setting the following property to true or false: Application.Current.Host.Content.IsFullScreen

Normally Silverlight applications will only stay in full screen mode until a user hits the <ESC> key or until the application loses focus. For example, if the user has multiple monitors and they click on another application in another monitor this will cause the Silverlight application to return to windowed mode. If you want to prevent your Silverlight application from leaving full screen mode in this case you can do so by setting:

Application.Current.Host.Content.FullScreenOptions = 
                 System.Windows.Interop.FullScreenOptions.StaysFullScreenWhenUnfocused;

 

Now, when a user clicks on another application in another monitor they will be prompted with the following dialog:

image

If the user clicks ‘Remember my answer’ and the “Yes” button they will only need to be prompted this one time.

In the following demo below I have added a button that toggles full screen mode as well as an event that will update the status text to show whether we are in full screen mode or not:

App.Current.Host.Content.FullScreenChanged += ((sender, args) =>
{
    if (App.Current.Host.Content.IsFullScreen)
    {
        ModeTB.Text = "Mode=Full Screen";
    }
    else
    {
        ModeTB.Text = "Mode=Windowed";
    }
});

 

Demo:

[silverlight: Tip31_Pinning.xap]

Thanks,

–Mike

2 Comments

Leave a comment
  1. sia
    24. Feb, 2011 at 10:51 am #

    How can i add this lines to silverlight?

  2. Anuj Seth
    14. May, 2011 at 10:46 pm #

    Thanks for the tip. The text that the user gets to see in the popup is kind of complicated, is there a way to customize it ? I mean, most people don’t really know what focus means etc.