Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Prior to SilverLight 5, there was no way to create new native operating system windows. Sure there was the child window class, but I think it is really is Silverlight control. The operating system is unaware that it exists. Native windows have certain advantages. For one, they can move outside the bounds of the Silverlight application, perhaps onto a second monitor. Operating system windows are available on both the Mac and PC, with one stipulation. Your Silverlight application must be an out-of-browser application running in elevated trust. For this demonstration I'm going to use Visual Studio and a project called Creating Native Windows.
I'd like to review the out-of-browser and elevated trust settings before continuing. Open your Properties window, click on the Silverlight tab, and then scroll down to the bottom. This check box, Enable running application out of the browser is what makes it an out-of-browser application, and then inside this button dialog, this is setting called Require elevated trust when running outside the browser. You need those two settings enabled before continuing. I'm going to create a native window. There is no way to crate a native window in XAML; you must do it in code.
I will start by writing some code in this first button. This first line of code instantiates a new window class, then I set a few properties. These two settings change the title on the window and also set it to the Normal WindowState. Next, I set the size and width, and then I set the content--the insides of the window--to null. And now I'm ready to show the window, win.Show.
Press F5 to run the application, click on the button. Notice that this is not like the child window; it's outside the browser window. It is a normal window. It has the Window menu, it has the Minimize and Maximize buttons. You can size it. You can dock it to the edge of the window as necessary. All of the standard native window behave you expect. Now it has no content, the good news is that this section of the window can be any valid Silverlight content. So let me show you how I'm going to fix this. I'm going to copy this code, paste it in here, and then instead of saying win.Content = null, I'll change that and say equal to new MainPage.
Now you might have noticed if you were paying attention that I'm inside a class called MainPage. So I'm creating the instance of the MainPage again and putting it inside my native window. I'll click on this one and this one and infinite number of windows with that content. There is more that you can do with native windows. You can get a list of active windows or modify the window chrome. To make the application run into full- size, kiosk-style window requires creating a full-screen application. That's what we'll look at in the next movie.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 101301 Viewers
61 Video lessons · 88061 Viewers
71 Video lessons · 71913 Viewers
56 Video lessons · 103737 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.
Your file was successfully uploaded.