Partilhar via


Content.FullScreenChanged Event

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Occurs when the hosted Silverlight plug-in either enters or exits full-screen mode.

Namespace:  System.Windows.Interop
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Event FullScreenChanged As EventHandler
public event EventHandler FullScreenChanged

Remarks

The event does not report the state. When you handle the event, immediately check IsFullScreen.

Examples

The following code example demonstrates how to use this event.

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

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.