The Silverlight 5 beta version was released yesterday. With excitement, we updated the development environment to the Silverlight 5 beta version today and introduced the first new feature of Silverlight 5 beta: multi-Window Display in OOB mode.
Now we start to install the Silverlight 5 beta version. First we need to install the vs2010 SP1 Patch for vs2010. Then we need to download the Silverlight 5 beta tools for Visual Studio SP1, and the installation is completed step by step, finally, we will download the new feature of Silverlight 5 features document. Now we can embark on the development journey of Silverlight 5.
The support for new windows under Silverlight 5 beta is based on the OOB mode, so we first create a Silverlight 5 ApplicationProgramRight-click Project Properties> allow applications running outside the Browser> click "settings outside the browser"> "enhance trust when running outside the browser. As shown in:
Then we are in the backgroundCodeEnter the following code to bring up a window. click the button in the window to continue the window. Of course, all pop-up child Windows depend on the parent window. (Tip: the size of the window class modified in Silverlight 4.0 is the size of its own window, and the window cannot be displayed)
Public Partial Class Mainpage: usercontrol
{
Public Mainpage ()
{
Initializecomponent ();
Popwindow ( 400.0 , 20.0 , " The " + Flag + " Instances window " );
}
Public Static Int Flag = 0 ;
Private Void Popwindow ( Double Left, Double Top, String Title)
{
// Set common properties of window
Window testwindow = New Window ();
Testwindow. Height = 400 ;
Testwindow. Width = 500 ;
Testwindow. Top = Top;
Testwindow. Left = Left;
Testwindow. Title = Title;
Testwindow. Visibility = Visibility. visible;
// Add a canvas with buttons and set the background color of the canvas to white.
Button BTN = New Button ();
BTN. Width = 80.0 ;
BTN. Height = 30.0 ;
BTN. Content = " Click " ;
BTN. Margin = New Thickness ( 5 , Top + Flag * 10 , 0 , 0 );
BTN. Click + = New Routedeventhandler (btn_click );
Canvas canvas = New Canvas ();
Canvas. Children. Add (BTN );
Canvas. Background = New Solidcolorbrush (colors. White );
Testwindow. Content = Canvas;
// The default window value is windowstate. Normal.
Testwindow. windowstate = Windowstate. normal;
// Windowstate. maximized; window Maximization
// Windowstate. minimized; minimized window
// Windowstate. Normal; normal window
Void Btn_click ( Object Sender, routedeventargs E)
{
Popwindow ( 400.0 , 20.0 , " The " + Flag + " Instances window " );
}
}
This instance is created using vs2010 + Silverlight 5 beta. If you need the source code, click sl5first.zip to download it.