Page view counter

Silverlight Tips of the Day - Blog by Mike Snow

Game Programming with Silverlight

Silverlight Tip of the Day #35 – Full Screen Mode Implementation

To have your application enter into full screen mode all you have to do is execute the following line of code:

Application.Current.Host.Content.IsFullScreen = true;

Once in full screen Silverlight will briefly show the following message that will fade away in a few seconds:

image

At this point the <ESC> key is reserved for exiting out of full screen mode. Of course, you can also exit manually by setting IsFullScreen = false.

Limitations/Restrictions to be aware of:

  • For security reasons, you cannot set the property IsFullScreen directly but rather only in the response to a user input event such as a button click.
  • To prevent password spoofing, only the following keyboard inputs are allowed while in full screen mode:
    • space
    • arrow keys
    • tab
    • home
    • enter
    • end
    • pageup/pagedown

Run a complete demo here: http://silverlight.services.live.com/invoke/66033/Full%20Screen/iframe.html

Sample Source for Page.xaml.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
 
namespace FullScreen
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
        }
 
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ToggleFullScreen();
        }
 
        private void ToggleFullScreen()
        {
            Application.Current.Host.Content.IsFullScreen = !Application.Current.Host.Content.IsFullScreen;
        }
    }
}

Page.xaml:

<UserControl x:Class="FullScreen.Page"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="300">
    <Canvas>
        <Button Click="Button_Click" Content="Toggle Full Screen"></Button>
    </Canvas>
</UserControl>

Thank you,
--Mike Snow

 Subscribe in a reader

Comments

Microsoft Weblogs said:

To have your application enter into full screen mode all you have to do is execute the following line

# September 4, 2008 5:57 PM

2008 September 05 - Links for today « My (almost) Daily Links said:

Pingback from  2008 September 05 - Links for today &laquo; My (almost) Daily Links

# September 5, 2008 1:50 AM

Silverlight news for September 5, 2008 said:

Pingback from  Silverlight news for September 5, 2008

# September 5, 2008 4:59 AM

Rui-Marinho said:

Well. i just really don't understand why it dosen't allow us to use the normal keyboard... it should be a great to use this to web software to plasma tvs and so..

i hope microsoft realizes that it would be a great thing to have in the RTM version..

mike do u know if it would be possible?

flash allows this i think.. i be behind them? :P

Greetings

Rui Marinho

# September 5, 2008 5:35 AM

alvipeo said:

This doesn't work in FF though...

# September 5, 2008 6:19 AM

Dew Drop - September 5, 2008 | Alvin Ashcraft's Morning Dew said:

Pingback from  Dew Drop - September 5, 2008 | Alvin Ashcraft's Morning Dew

# September 5, 2008 8:12 AM

Dew Drop - September 5, 2008 | Alvin Ashcraft's Morning Dew said:

Pingback from  Dew Drop - September 5, 2008 | Alvin Ashcraft's Morning Dew

# September 5, 2008 8:12 AM

mike.snow said:

Hi Rui, unfortunately I am not aware of any changes to the keyboard in full screen.

# September 5, 2008 9:05 AM

Amin Mahpour » Blog Archive » Silverlight post collections said:

Pingback from  Amin Mahpour  &raquo; Blog Archive   &raquo; Silverlight post collections

# September 5, 2008 11:13 AM

Mirrored Blogs said:

Post: Approved at: Sep-5-2008 Building Line-of-Business Apps with Silverlight 2 Dr. Dobb&#39;s article

# September 5, 2008 3:05 PM

Community Blogs said:

Michael Washington on Silverlight Desktop for DNN, Corey Schuman with Play/Paus button, Shawn Wildermuth

# September 6, 2008 12:18 PM

Visual Web Developer Team Blog said:

&#160; Silverlight Tip of the&#160; Day #39 Title : How to Create a Zoom Toolbar Demo: silverlight.services.live.com/.../iframe.html

# September 11, 2008 1:21 AM

MarauderzMY said:

You cannot allow full keyboard access in a fullscreen application because it'll allow people to create the impression of a fake site (ie your bank, etc. etc.) and coax you into typing in your username and password.

and no, the short few second message that says press esc to return to browser wouldn't help that much to let people know that no.. this is NOT their bank's logon page.

# September 12, 2008 12:07 AM

DZaK said:

Hi,

Thank you for nice Tip of the Day!

I found also article about full screen mode, but with resize options.

geekswithblogs.net/.../full-screen-mode-in-silverlight-2.0-rtw-applications.aspx

Bests,

John

# November 7, 2008 7:46 PM

Silverlight Tips of the Day - Blog by Mike Snow said:

The purpose of this post is to create an outline summary all the blogs from my Silverlight tips of the

# January 2, 2009 5:56 PM

o UAU nosso de cada dia said:

essa lista eu copiei desse blog bárbaro (acompanhe por RSS você também): uma lista de dicas super úteis

# January 3, 2009 6:25 AM

anthony.selby said:

So ... if full screen is mainly for video and pictures ... then how is a 640x480 video going to look good if my res is 1280x1024 ... and the user clicks the full screen button, I agree completely with the idea of security except as much as we would like it to be all the content isn't HD and no matter how well you scale things they don't look all that good when you expand them that much ... full screen should be able to change the users resolution ... and as soon as they exit full screen it should go back.

# January 4, 2009 1:40 AM

mike.snow said:

The best thing to do is to center your app in your browser without scaling. All full screen is doing is hiding your browser and desktop and making your application take the entire space. If you do not want to scale it you should simply center it.

# January 5, 2009 12:02 PM