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.