Detecting when a Silverlight app enters full screen mode

Obviously you know when a users clicks your full screen button but a the user can press escape to exit full screen mode at any time, an alternative is to respond to the FullScreenChanged event.

For example:

     public partial class MainPage : UserControl
        public MainPage()
            App.Current.Host.Content.FullScreenChanged += new EventHandler(FullScreenChanged);

        void FullScreenChanged(object sender, EventArgs e)
            if (App.Current.Host.Content.IsFullScreen)
                txtFullScreen.Text = "Running in full screen.";
                txtFullScreen.Text = "Not running in full screen.";

        private void btnFullScreen_Click(object sender, RoutedEventArgs e)
            App.Current.Host.Content.IsFullScreen = true;

The above assumes a button to enable the user to select full screen and a textblock:


<UserControl x:Class="blog_misc_temp.MainPage"
    xmlns:d="" xmlns:mc=""
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
  <Grid x:Name="LayoutRoot">
            <TextBlock Name="txtFullScreen" Text="Not running in full screen."/>
            <Button Click="btnFullScreen_Click" Content="Enter Full Screen"></Button>



Add comment