Mode forms in Asp.net Silverlight

Source: Internet
Author: User

In fact, it is not difficult to develop the form mode in Silverlight. It is much easier to construct the form with DIV in HTML. However, it is still necessary to make the form reusable and normative. If the development friends of SL want to steal a bit of laziness, they can directly use some ready-made mode forms. Code Here I will introduce a sl framework called silverlightfx, which contains a form class. As long as your XAML class inherits the Form class, you can easily use the mode form. Specific aspects can refer to his sample project, here is the connection of silverlightfx for everyone http://projects.nikhilk.net/SilverlightFX
It is not difficult to write the code of the mode form by yourself. Here I will give you a simple piece of code.

The first is the base class and delegation of the mode form.Copy codeThe Code is as follows: public class modaldialog: usercontrol
{
Public event eventhandler closed; // dialog Close event
Public event modaleventhandler completedcallback; // call back event

Public void close ()
{
If (closed! = NULL)
{
Closed (this, eventargs. Empty );
}
}

Public void handlecallback (modaleventargs E)
{
If (completedcallback! = NULL)
{
Completedcallback (this, e );
}
}
}

Public interface imodaldialogopener
{
Void showmodaldialog (modaldialog DIALOG );
Void closemodaldialog ();
}
Public class modaleventargs: eventargs
{
Public object result {set; get;} // The result of this Modal Dialog
}
Public Delegate void modaleventhandler (Object sender, modaleventargs E );

All controls that you want to bring up in a mode form can inherit the modaldialog class, and the parent form must implement the imodaldialogopener interface and implement the methods in it; as for modaleventarg, this parameter class can be expanded by developers themselves. Here I only provide the result attribute of the object type.

Next, the masking layer elements are given in the parent form.Copy codeThe Code is as follows: <! -- Use for loading Modal Dialog -->
<Border X: Name = "Placeholder" verticalalignment = "stretch" horizontalalignment = "stretch"
Visibility = "Collapsed" width = "1600" Height = "1200"
Background = "# ff8a8a8a" opacity = "0.9" canvas. zindex = "1000"/>

This masking layer can also be customized by developers, such as the length, width, transparency, and background color.

Finally, the code of the parent form implements the showmodaldialog method and closemodaldialog method. The idea is to assign a value to the child of the masking layer as the mode form class, then display the masking layer, and disable the opposite.

The mode form is introduced here, and I will provide it in time if there is better code.

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.