web 2.0

News: Windows Phone 7 Phones Running Silverlight


Silverlight Can Go Full Screen and Back

So you want your Silverlight video player to play in full screen? No problem! It's pretty easy to go into full screen mode, hiding everything including browser frame, in Silverlight. It's just a line of code:

Application.Host.Content.IsFullScreen = True 

While in full screen mode, user can press ESC key to exit full-screen mode, or your Silverlight application can exit programatically by:

Application.Host.Content.IsFullScreen = False

You can easily toggle between full screen modes by:

VB.NET
Application.Host.Content.IsFullScreen = Not Application.Host.Content.IsFullScreen

C#
Application.Host.Content.IsFullScreen = !Application.Host.Content.IsFullScreen;

The Content class exposes two events FullScreenChanged() which fires when the full screen mode is changed, and Resized() event which fires when the host element is resized (not when browser is resized). You can use these events to detect when user gets into and out of full screen mode. It's also worth mentioning that all keyboard events will not fire in full screen mode, only mouse events will. This feature is to protect user from password spoofing and other impersonation attacks.

View Online Demo - Download Source Code (14.34 kb)

Tags:

Silverlight 1.1 | Silverlight 2.0 | Tutorial

Comments

zxc , on 8/1/2008 8:57:22 PM Said:

zxc

I am not a dang programmer, how to use this base function (which should be embedded by default).

verna , on 9/30/2008 3:46:38 PM Said:

verna

Application.Host.Content.IsFullScreen = !Application.Host.Content.IsFullScreen;

Deric B. , on 11/7/2008 12:42:44 PM Said:

Deric B.

Hi,
Thank you for nice article! I found also article about - how to extends full screen mode to resize options. I hope you will find it useful.

geekswithblogs.net/.../....0-rtw-applications.aspx

Bests,
Deric

Neo , on 1/15/2009 5:08:18 PM Said:

Neo

Thanks to verna for pointing out the mistake.

Carlos , on 3/24/2009 4:41:26 AM Said:

Carlos

Tried to look at this and it is telling me to download Silverlight in Firefox. I already have to most recent versions. Tried to view it in IE7 and got a Silverlight error message.

Oliver , on 4/24/2009 3:36:53 AM Said:

Oliver

I had to use Application.Current.Host.Content.IsFullScreen = !(Application.Current.Host.Content.IsFullScreen); but otherwise it worked great thanks.

Rohs Screening , on 8/6/2009 9:33:35 PM Said:

Rohs Screening

Hi,
Glad to stumble your article..keep up the good work...

topsy.com , on 5/19/2010 9:06:35 AM Said:

pingback

Pingback from topsy.com

Twitter Trackbacks for
        
        Silverlight Can Go Full Screen and Back
        [silverlightexamples.net]
        on Topsy.com

Add comment


(Will show your Gravatar icon)

biuquote
  • Comment
  • Preview
Loading