Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
When you create a desktop application, it is common to launch it in full-screen mode. In web applications, however, this is not as easy. Because web apps run inside the browser, it is the browser that is maximized. The solution for the HTML world has been to remove the browser chrome and then ask for a maximum-sized window. Silverlight has a full- screen mode for this purpose. For this demonstration, I will use Visual Studio and a project called UsingFullScreenmode. This is my user interface for my application. I have two text boxes for the users to enter some comments about their vacation stay, and then they can click on this Update profile.
I would like to run this application in full-screen mode, so I've provided two buttons: Go FullScreen and Restore to Normal Screen. Here is what the code looks like. It just takes a single line of code to switch to full-screen mode and a single line of code to switch out of full-screen mode. This is how you would determine if you're in a full-screen mode, by writing an if statement like this. Let's run the application and see what it looks like. I want to be clear about the difference between a window being in maximized mode, like this, as opposed to being in full-screen mode.
Let's watch the difference. Go FullScreen. Notice that there is no window chrome? You might have noticed there was also a notification to the user. Let's watch that again. I'll click on Go FullScreen and in the center of the screen, you'll see this gray box pop up. This is just to notify the user that they are in full-screen mode and it provides a way for them to escape full-screen mode if I didn't provide this Restore to Normal Screen button. They can press Escape to go back to normal mode. There are restrictions placed on your application if you use the full-screen mode.
Some of the limitations are included to prevent application spoofing. Imagine for a moment that a hacker shows a spoof screen of your favorite application and tricks you into revealing sensitive information. To combat this issue, Microsoft forbids certain actions for full-screen apps. For starters, you cannot enter full- screen mode without the user approval. On my application, they clicked on the button to enter the full-screen mode. Silverlight only permits one app to be in full-screen mode at a time. It also blocks most keystrokes from reaching your application. Again, this is due to security concerns.
In full-screen mode, you get access to the arrow keys, then navigation keys like Home and Page Up, and you also get access to Tab and Spacebar. If you create an elevated-trust application and the user grants permission to your app, you can also gain full keyboard access. Let's take a look. I'm in normal mode in my application. The user can come in here and type in the name of their bungalow they stayed in, and their comments, and then they can click on the Update profile button.
Now let's enter full-screen mode. I'm typing in this text box--you can't see it, but I am--and nothing is showing up in the text box. I'm being blocked because I'm in full-screen mode. To allow keystrokes, I need to go to elevated trust. To do that, I'll switch back to Visual Studio, open up my Property window, choose Silverlight, and then scroll down, and check Require elevated trust when running in-browser. Press F5 to run the application again, go to full-screen mode, and now I'm able to type in the text box.
There's another issue with being in full-screen mode, that's what happens when you switch to another application. I'm going to switch to Notepad. Do you see what happened to my full-screen application? It's now back in normal mode. This doesn't work very well if I was trying to watch a movie on another screen on my computer and I want to do some work on the main screen, now I lost my full-screen movie viewer. So I can asked to be kept in full-screen mode. Switch back to my project, go to my code behind, and let me show you the code on that checkbox.
When the user checks the checkbox, I set this FullScreenOptions to StaysFullScreenWhenUnfocused. And when they uncheck the checkbox, I set it back to Options = None. Now, let me switch my Required elevated trust back to normal before running this demo. Press F5. I'll check Keep Full Screen, and then I'll click on Go FullScreen. Silverlight is not going to allow this to happen unless the user permits it, so the user needs to press Yes or No here.
They can also click on this check box to Remember my answer. I'm going to say Yes to stay in full-screen mode, and now I'm going to switch back to Notepad and you see that Notepad is on top of my full-screen application. I can change focus back and forth between these two, and it won't move my application out of full-screen mode. Full-screen is a useful concept. It's perfect for certain applications, like movie viewers. I'm sure you'll find a use for full screen in one of your applications.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 105383 Viewers
56 Video lessons · 117101 Viewers
71 Video lessons · 86317 Viewers
131 Video lessons · 41253 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.