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
.png)
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.
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 });
}
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.
Note: |
|---|
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.