How to Use the pop-up layer on the Silverlight page

Source: Internet
Author: User

Add a button on the XAML page as follows:

View code

 <  Grid  X: Name  = "Layoutroot"  Background  = "White"     >  
< Button Width = "100" Height = "50" X: Name = "Showpopup" Click = "Showpopup_click"
Content = "Show popup" />
</ Grid >

AfterCodeAdd the following code to the page. XAML. CS file:

View code

 Popup P  =    New  Popup ();
Private Void Showpopup_click ( Object Sender, routedeventargs e ){
// Create a panel control that contains other controls
Stackpanel Panel1 = New Stackpanel ();
Panel1.background = New Solidcolorbrush (colors. Gray );
// Create a button
Button button1 = New Button ();
Button1.content = " Close " ;
Button1.margin = New Thickness ( 5.0 );
Button1.click + = New Routedeventhandler (button#click );
// Create text label
Textblock textblock1 = New Textblock ();
Textblock1.text = " The popup Control " ;
Textblock1.margin = New Thickness ( 5.0 );
// Add text label and button to panel
Panel1.children. Add (textblock1 );
Panel1.children. Add (button1 );
// Set Panel as the sub-panel of the pop-up layer. When panel is displayed, it is displayed as a pop-up layer.
P. Child = Panel1;
// Set location
P. verticaloffset = 25 ;
P. horizontaloffset = 25 ;
// Show the popup.
P. isopen = True ;
}
Void Button#click ( Object Sender, routedeventargs e ){
// Close the pop-up layer
P. isopen = False ;
}

Note: you must add a reference to the system. Windows. Controls. primitives naming control.
Run the applicationProgram. You can see a button on the page. When you click a button, a bullet with text labels and buttons
The output layer is displayed. When you click the button in the pop-up layer, the pop-up layer will be closed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.