Silverlight
Full-Screen Support

Silverlight provides functionality for displaying the Silverlight plug-in in full-screen mode.

This topic contains the following sections.

Embedded Mode and Full-Screen Mode

The Silverlight plug-in can display in either embedded mode or in full-screen mode:

  • In embedded mode, the plug-in displays within the Web browser.

  • In full-screen mode, the plug-in resizes to the current resolution of the screen and displays on top of all other applications, including the browser.

The following illustrations show the differences between embedded mode and full-screen mode.

Silverlight plug-in displaying in embedded mode

Embedded mode
Silverlight plug-in displaying in full-screen mode

Full-screen mode
Setting Full-Screen Mode

The Content..::.IsFullScreen property determines whether the Silverlight plug-in displays as a full-screen plug-in or as an embedded plug-in. If you set the IsFullScreen property to true, the Silverlight plug-in displays in full-screen mode; otherwise, the plug-in displays in embedded mode. If a Web page hosts multiple Silverlight plug-ins, only one plug-in can be in full-screen mode at one time. Additionally, the plug-in will not display any HTML content in full-screen mode. This prevents full-screen HTML overlay effects using windowless mode.

When a Silverlight plug-in displays in full-screen mode, it briefly displays the message "Press ESC to exit full-screen mode". This message alerts the user that the application is now in full-screen mode, and provides information about how to return to embedded mode.

Full-screen mode message

Press ESC to exit full-screen mode.

A Silverlight plug-in can enable full-screen mode only in response to a user-initiated action. This means that you can programmatically switch to full-screen mode only in a user-input event handler. If you try to set the IsFullScreen property to true in a Startup event handler, for example, the property setting is ignored. Limiting the actions that enable full-screen mode ensures that the user is always the initiator of full-screen mode behavior. This prevents malicious applications from spoofing the appearance of the operating system or other programs.

NoteNote:

You should avoid using OpenFileDialog and SaveFileDialog in full screen mode.

When a Silverlight plug-in is in full-screen mode, it disables most keyboard events. This limitation of keyboard input during full-screen mode is a security feature, and is intended to minimize the possibility of unintended information being entered by a user. In full-screen mode, the only input allowed is through the following keys.

UP ARROW, DOWN ARROW, LEFT ARROW, RIGHT ARROW, SPACEBAR, TAB, PAGE UP, PAGE DOWN, HOME, END, ENTER

The Silverlight plug-in does not support OpenFileDialog and SaveFileDialog in full-screen mode. In most cases, displaying one of these dialog boxes in full-screen mode will cause the plug-in to revert to embedded mode. However, to avoid issues on some browsers, you should exit full-screen mode before using these classes.

Multitouch input is not supported in full-screen mode.

The following code example shows how to enable and disable full-screen mode for a Silverlight plug-in by toggling the IsFullScreen property value.

Visual Basic
Private WithEvents rootPage As Page = New Page()
Private WithEvents htmlContent As Content
Private Sub Application_Startup(ByVal o As Object, ByVal e As StartupEventArgs) Handles Me.Startup
    Me.RootVisual = rootPage
    htmlContent = Me.Host.Content
End Sub

Private Sub ToggleFullScreen(ByVal sender As Object, _
    ByVal e As MouseButtonEventArgs) Handles rootPage.MouseLeftButtonDown
    Me.Host.Content.IsFullScreen = Not Me.Host.Content.IsFullScreen
End Sub

Private Sub DisplaySizeInformation( _
    ByVal sender As Object, ByVal e As EventArgs) _
    Handles htmlContent.FullScreenChanged, htmlContent.Resized

    Dim message As String = String.Format( _
        "ActualWidth={0}, ActualHeight={1}", _
        Me.Host.Content.ActualWidth, _
        Me.Host.Content.ActualHeight)

    rootPage.LayoutRoot.Children.Clear()
    Dim t As New TextBlock()
    t.Text = message
    rootPage.LayoutRoot.Children.Add(t)

End Sub
C#
Page rootPage = new Page();
private void Application_Startup(object sender, StartupEventArgs e)
{
    this.RootVisual = rootPage;

    rootPage.LayoutRoot.MouseLeftButtonDown +=
        delegate(Object s, MouseButtonEventArgs args) {
            this.Host.Content.IsFullScreen =
                !this.Host.Content.IsFullScreen;
        };

    this.Host.Content.FullScreenChanged += 
        new EventHandler(DisplaySizeInformation);

    this.Host.Content.Resized += 
        new EventHandler(DisplaySizeInformation);
}

private void DisplaySizeInformation(Object sender, EventArgs e)
{
    String message = String.Format(
        "ActualWidth={0}, ActualHeight={1}",
        this.Host.Content.ActualWidth,
        this.Host.Content.ActualHeight);

    rootPage.LayoutRoot.Children.Clear();
    rootPage.LayoutRoot.Children.Add(
        new TextBlock { Text = message });
}

The Size of the Plug-in in Full-Screen Mode

When a Silverlight plug-in is displayed in full-screen mode, the plug-in's size is equal to the current resolution of the screen. However, the values of the width and height properties of the plug-in are not affected during the switch to full-screen mode. To determine the true size of the plug-in in full-screen mode, use the Content..::.ActualWidth and Content..::.ActualHeight properties. In full-screen mode, these properties are set to the current resolution of the screen.

When a Silverlight plug-in in full-screen mode switches back to embedded mode, the plug-in size reverts to the values of the width and height properties.

For more information about the width and height properties, see Property Values of the HTML Object Element.

Performance Characteristics During a Mode Change

Switching between embedded and full-screen modes has minimal effect on performance for content that is contained within the Silverlight plug-in. This means, in most cases, that the playback of audio or video content is seamless.

NoteNote:

For best performance, when your application goes into full-screen mode, hide or disconnect from the tree all objects that are not being rendered in full-screen mode. You can hide an object by setting its Visibility property to Collapsed.

Full-Screen Windowless Silverlight Plug-Ins

A Silverlight plug-in whose Windowless property is set to true always draws its background color at full opacity when displayed in full-screen mode. However, when the Silverlight plug-in returns to embedded mode, the background color reverts to its previous opacity value.

Returning to Embedded Mode

A Silverlight plug-in that is in full-screen mode can return to embedded mode in several ways. The simplest way to leave full-screen mode is for the user to enter a keystroke or keystroke combination:

  • Windows users should press ESC or ALT+F4.

  • Macintosh users should press ESC.

In addition, if a Silverlight plug-in that is in full-screen mode loses focus, it returns to embedded mode. A Silverlight plug-in in full-screen mode can lose focus in a multi-monitor configuration when another window gains focus through a user action. For example, switching between tasks in Windows by using the ALT+TAB key combination causes the current application to lose focus and the next application to gain focus.

Setting the IsFullScreen Property to False

When a Silverlight plug-in is displayed in full-screen mode, setting the IsFullScreen property to false returns the plug-in to embedded mode. When a Silverlight plug-in switches back to embedded mode from full-screen mode, the plug-in size reverts to the values of the width and height properties.

The FullScreenChanged Event

The Content..::.FullScreenChanged event occurs whenever the IsFullScreen property changes. You can handle this event to change your user interface in full-screen mode.

NoteNote:

The Resized event does not occur when the Silverlight plug-in enters full-screen mode. However, you typically perform similar layout changes in handlers for both the Resized and FullScreenChanged events.

See Also

Reference

Concepts

Tags :


Community Content

Giganerd
Keyboard Example
A keyboard event example while in full-screen would be useful.

Tags :

jalchr
Feature Required: Start in fullscreen
Hello, I have a suggestion for starting up in full-screen, right from the beginning. I hope this is the right place, if not please direct it to Silverlight team.
Your limitation stated here:
" A Silverlight plug-in can enable full-screen mode only in response to a user-initiated action. This means that you can programmatically switch to full-screen mode only in a user-input event handler. If you try to set the IsFullScreen property to true in a Startup event handler, for example, the property setting is ignored. Limiting the actions that enable full-screen mode ensures that the user is always the initiator of full-screen mode behavior. This prevents malicious applications from spoofing the appearance of the operating system or other programs. "

But again in full screen mode, the following is true
" When a Silverlight plug-in is in full-screen mode, it disables most keyboard events. This limitation of keyboard input during full-screen mode is a security feature, and is intended to minimize the possibility of unintended information being entered by a user. In full-screen mode, the only input allowed is through the following keys.
UP ARROW, DOWN ARROW, LEFT ARROW, RIGHT ARROW, SPACEBAR, TAB, PAGE UP, PAGE DOWN, HOME, END, ENTER
"
I suggest, if silverlight is needed to start-in-fullscreen, example a slide show, then in addition to above limitations, add a water mark that fades in 1min at least (configurable too) that informs the user that this is a silverlight application not a spoofing one. Or if the user inputs something (which is the main problem) and wants to submit, through network stack, a special confirmation dialog intercepts the submission and requires explicit confirmation that serves the same as " ... in response to a user-initiated action. ", So this is a post-security measure versus a pre-security measure

I hope we see this feature in Silverlight 3 Final.

Page view tracker