pattern forms in asp.net Silverlight-practical tips

Source: Internet
Author: User
Tags call back silverlight
It's not hard to develop a pattern form in Silverlight, much easier than using div in HTML, but it takes a little time to be reusable and prescriptive. If SL's development friends want to steal a little lazy, with some out-of-the-box pattern form codes, I'm here to introduce a SL framework called SILVERLIGHTFX, which has a form class that makes it easy to use a pattern form if your XAML class inherits form classes. The specific aspect may refer to his sample project, here gives the SILVERLIGHTFX connection to everybody Http://projects.nikhilk.net/SilverlightFX
If you want to write the code of the mode form is not difficult, here I give a simple code


The first is the base class of the modal form and the delegate
Copy Code code 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 want to pop up in a modal form can inherit Modaldialog this class, and then the parent form must implement the Imodaldialogopener interface and implement the method inside; As for Modaleventarg, this parameter class can be extended by the developer itself, I only provide a result property of type object.

Next, give the masking layer elements in the parent form
Copy Code code 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"/>

The masking layer can also be customized by the developer, such as long width, transparency, background color, and so on.

Finally, in the mother form code is to implement the ShowModalDialog method and Closemodaldialog method, the idea is nothing more than the shadow layer of the child assigned to the pattern form class, then show the masking layer;

The pattern form is introduced here, and later if there is better code I will be in time to serve.
Related Article

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.