Flash Components      Flash Menu      Flash Gallery      Flash Slideshow      FLV Player      Flash Form      MP3 Player      PhotoFlow      Flash CMS      3D Wall      Flash Scroller

Flash / AS

Silverlight

WPF

ASP.net / PHP

Photoshop

Forums

Blog

About

 


FlashComponents
  Galleries
  Slideshows
  Menus
  Design & Effects
  Audio & Video
  User Interface
  Templates

 

 

Going Full Screen
       by kirupa  |  17 June 2008

Most commonly, you interact with your Silverlight application as a component as part of a larger web page. There are many cases, though, where you would want your undivided attention to be paid to your Silverlight application - such as when you are watching a movie or playing with some Deep Zoom content.

In those cases, you can give your users the ability to run your application in full screen. To see an example of what this looks like, click on the Full Screen button in the below example:

Get Microsoft Silverlight

When you clicked on the Toggle Full Screen button, your Silverlight application will have gone, as expected, full screen where your taskbar, browser buttons, etc. are all hidden from view. Clicking the button again will return you back to the application's default size.

 The code for doing this is fairly straightforward:

private void GoFullScreen(object sender, RoutedEventArgs e)
{
if (!Application.Current.Host.Content.IsFullScreen)
{
Application.Current.Host.Content.IsFullScreen = true;
}
else
{
Application.Current.Host.Content.IsFullScreen = false;
}
}

The code can be summarized as follows. You check to see whether you are currently in full screen mode. If you are not, then you switch into full screen mode. If you are already in full screen mode, then you will return to your default, non-full screen view.

Let's look a the code in greater detail:

if (!Application.Current.Host.Content.IsFullScreen)
{
Application.Current.Host.Content.IsFullScreen = true;
}
else
{
Application.Current.Host.Content.IsFullScreen = false;
}

In the above line, I have an if statement that checks whether you are currently in full screen mode or not. I accomplish that via checking what the value of Application.Current.Host.Content.IsFullScreen is. This statement returns a true or false depending on whether your application is in full screen or not.

I am not doing a straightforward comparison. I am actually negating the value returned by the IsFullScreen property by using the ! (exclamation mark). What this if statement actually says is "If Application is NOT Full Screen" then do something, otherwise, do something else.


When your if statement determines you are not currently in full screen mode, the following line gets executed:

if (!Application.Current.Host.Content.IsFullScreen)
{
Application.Current.Host.Content.IsFullScreen = true;
}
else
{
Application.Current.Host.Content.IsFullScreen = false;
}

This line simply sets your IsFullScreen property to true. Once this happens, you automatically go into full screen mode. There is nothing extra you have to do.


If you were already in full screen mode when you called your if statement, your if statement will return a false and send you to the following line of code:

if (!Application.Current.Host.Content.IsFullScreen)
{
Application.Current.Host.Content.IsFullScreen = true;
}
else
{
Application.Current.Host.Content.IsFullScreen = false;
}

In this line, we are setting our IsFullScreen property to false, and this returns your view back to its original state where your Silverlight application is back to its normal size.

Keyboard and Mouse in Full Screen
When you are in full screen mode, though, your keyboard and mouse functionality is reduced for security reasons. You only have mouse button, arrow keys, and space bar support. You do not have the ability to use other keys on your keyboard or the mouse wheel.


I hope the information helped. If you have any questions or comments, please don't hesitate to post them on the kirupa.com Forums. Just post your question and I, or our friendly forum helpers, will help answer it.

The following is a list of related tutorial and help resources that you may find useful:

How to use the Forums
New, Upcoming, and In-Progress Tutorials
How to Help out kirupa.com
Writing Tutorials
 
Cheers!
Kirupa Chinnathambi
kirupaBlog


kirupa.com's fast and reliable hosting provided by Media Temple. flash components
The Text Animation Component for Flash CS3
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.
Check out our high quality vector-based design packs! Flash Effect Components

Flash Templates
CSS Templates
Dreamweaver Templates

flash menus, buttons and components
Digicrafts Components The best flash components ever!
Entheos Flash Website Templates Buy and sell FLAs at Ultrashock!
Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com Purchase & Download Flash Components
Learn how to advertise on kirupa.com