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.