Uses Silverlight to implement the masking effect.

Source: Internet
Author: User
This kind of effect is very common. When a user clicks an option or button on the page, a window is displayed, and other parts of the window are masked with translucent colors, and editing is not allowed.
Use Silverlight to make a summary:
1. Create a newwindow. XAML file. The default value is Code As follows: < Usercontrol X: Class = " Silverlightdemo. detailview "
Xmlns = " Http://schemas.microsoft.com/client/2007 "  
Xmlns: x = " Http://schemas.microsoft.com/winfx/2006/xaml "  
>
< Grid >

</ Grid >
</ Usercontrol >

2. Add a rectangle to the grid and set the opacity (transparency) and fill (fill color) attributes, as shown below:<Rectangle opacity="0.8"Fill="Lightgray"/>

3. the following content is what you want to display. I will show him a textblock and a close button as follows: < Border cornerradius = " 30 " Background = " # Ff5c7890 " Width = " 600 " Height = " 250 " >
< Stackpanel >
< Grid margin = " 30 " >
< Textblock text = " {Binding firstname} " Foreground = " White " Fontsize = " 20 " />
< Button content = " Close " Click = " Button_click " Width = " 50 " Height = " 30 " />
</ Grid >
</ Stackpanel >
</ Border >

4. The click method of the close button is as follows, that is, the visibility value is set as follows:Private void button_click (Object sender, routedeventargs E)
{
Visibility = visibility. collapsed;
}

5. OK, newwindow. the XAML file is here. You only need to use it in the file to be masked. Here I am on page. in the XAML file, click the button to bring up the mask. therefore:
First, introduce the namespace, which depends on your project. Here is:Xmlns: app="CLR-namespace: silverlightdemo"

then directly go to page. insert the custom control newwindow Into The XAML page. Remember to set the visibility attribute to collapsed so that it will not pop up during page loading. app: detailview X: name = " detailview " grid. rowspan = " 2 " visibility = " collapsed " />

Set the visibility value to visible in the Click Event of the button. The form is as follows: Private void button1_onclick (Object sender, routedeventargs e ){
Detailview. Visibility=Visibility. visible;
}


I have talked a lot about it, but it is actually a very simple problem!

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.