Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Silverlight
Visual Design
 Full-Screen Support
Silverlight
Full-Screen Support

Updated: November 2008

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

This topic contains the following sections.

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

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.

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.

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 following code example shows how to enable and disable full-screen mode for a Silverlight plug-in by toggling the IsFullScreen property value.

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 });
}

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

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.

Cc189023.alert_note(en-us,VS.95).gifNote:

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.

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 Content..::.FullScreenChanged event occurs whenever the IsFullScreen property changes. You can handle this event to change your user interface in full-screen mode.

Cc189023.alert_note(en-us,VS.95).gifNote:

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

Date

History

Reason

November 2008

Replaced code example for toggling full-screen mode.

Content bug fix.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker