Silverlight telerik Control Learning: radwindow

Source: Internet
Author: User

Almost all business systems have pop-up windows. There are two typical scenarios:

1. A dialog box is displayed, such as the following:

This is simple,CodeExample:

 
Dialogparameters pars = new dialogparameters (); pars. header = "information"; pars. content = "Hello World"; radwindow. Alert (PARs );

2. Click the "edit" button of a record to input the ID parameter. A window is displayed. After the record is edited and saved, the operation result is returned to the parent window.

In this scenario, the following requirements are required:

A) parameters passed by the parent window can be received in the pop-up window.

B) when the pop-up window is closed, the parent window should be able to differentiate what operations are used to close the window (for example, directly click the X button in the upper right corner to close the window, click Submit or cancel)

C) after the pop-up window is closed, the parent window should be able to know the operation result.

The sample code is as follows:

In the displayed XAML section:

<Telerik: radwindow X: class = "telerik. sample. popwinuserreg "xmlns =" http://schemas.microsoft.com/winfx/2006/xaml/presentation "xmlns: x =" http://schemas.microsoft.com/winfx/2006/xaml "xmlns: D =" http://schemas.microsoft.com/expression/blend/2008 "xmlns: MC =" http://schemas.openxmlformats.org/markup-compatibility/2006 "xmlns: telerik =" http://schemas.telerik.com/2008/xaml/presentation "MC: ignorable = "D" D: designheight = "480" D: designwidth = "640" windowstartuplocation = "centerscreen" header = "Member registration" padding = "10" width = "640" Height = "300" resizemode = "noresize"> <grid x: name = "layoutroot" background = "white"> <grid. rowdefinitions> <rowdefinition Height = "30"/> <rowdefinition Height = "30"/> <rowdefinition Height = "30"/> <rowdefinition Height = "30"/> <rowdefinition height = "30"/> <rowdefinition Height = "30"/> <rowdefinition Height = "30"/> <rowdefinition Height = "Auto" minheight = "10"/> <rowdefinition Height = "30"/> </grid. rowdefinitions> <grid. columndefinitions> <columndefinition width = "100"/> <columndefinition width = "*"/> </grid. columndefinitions> <textblock verticalalignment = "center" textalignment = "right"> Username: </textblock> <telerik: radmaskedtextbox grid. column = "1" grid. row = "0" name = "txtusername" verticalignment = "center" Mask = "aaaaaaaaaa" margin = "0, 0, 10, 0 "/> <textblock verticalignment =" center "textalignment =" right "grid. row = "1"> password: </textblock> <telerik: radmaskedtextbox grid. column = "1" grid. row = "1" name = "txtpassword" verticalignment = "center" margin = ","/> <textblock verticalignment = "center" textalignment = "right" grid. row = "2"> duplicate password: </textblock> <telerik: radmaskedtextbox grid. column = "1" grid. row = "2" name = "txtpassword2" verticalalignment = "center" margin = ","/> <textblock verticalalignment = "center" textalignment = "right" grid. row = "3"> birthday: </textblock> <telerik: radmaskedtextbox grid. column = "1" grid. row = "3" name = "txtbirthday" verticalalignment = "center" margin = "0, 0, 10, 0"/> <textblock verticalignment = "center" textalignment = "right" grid. row = "4"> Email: </textblock> <telerik: radmaskedtextbox grid. column = "1" grid. row = "4" name = "txtemail" verticalignment = "center" margin = ","/> <textblock verticalignment = "center" textalignment = "right" grid. row = "5"> phone number: </textblock> <telerik: radmaskedtextbox grid. column = "1" grid. row = "5" name = "txttel" verticalignment = "center" margin = ","/> <textblock verticalignment = "center" textalignment = "right" grid. row = "6"> mobile phone number: </textblock> <telerik: radmaskedtextbox grid. column = "1" grid. row = "6" name = "txtmobile" verticalignment = "center" margin = "0, 0, 10, 0"/> <stackpanel grid. row = "8" grid. column = "1" orientation = "horizontal" Height = "22"> <telerik: radbutton content = "Submit" width = "70" name = "btnsubmit" Click = "btnsubmit_click"/> <telerik: radbutton content = "Remove" width = "70" margin = "10, 0, 0, 0 "name =" btncancel "Click =" btncancel_click "/> </stackpanel> </GRID> </telerik: radwindow>

The XAML. CS section appears.

Using system; using system. collections. generic; using system. windows; using telerik. windows. controls; namespace telerik. sample {public partial class popwinuserreg: radwindow {public popwinuserreg () {initializecomponent (); this. loaded + = new routedeventhandler (popwinuserreg_loaded);} void popwinuserreg_loaded (Object sender, routedeventargs e) {dictionary <string, Object> dicpars = This. tag as dictio Nary <string, Object>; If (dicpars! = NULL) {string id = dicpars ["ID"]. tostring (); radwindow. alert ("input parameter:" + id) ;}} private void btncancel_click (Object sender, routedeventargs e) {This. dialogresult = false; this. close ();} private void btnsubmit_click (Object sender, routedeventargs e) {This. dialogresult = true; this. tag = "the value returned to the parent window is here! "; This. Close ();}}}

Parent window XAML. CS section:

Using system; using system. collections; using system. collections. generic; using system. LINQ; using system. net; using system. windows; using system. windows. controls; using system. windows. documents; using system. windows. input; using system. windows. media; using system. windows. media. animation; using system. windows. shapes; using telerik. windows. controls; namespace telerik. sample {public partial class forminput: User Control {popwinuserreg win = NULL; dictionary <string, Object> dicpars = new dictionary <string, Object> (); Public forminput () {initializecomponent (); this. loaded + = new routedeventhandler (forminput_loaded); this. unloaded + = new routedeventhandler (forminput_unloaded);} void forminput_loaded (Object sender, routedeventargs e) {win = new popwinuserreg (); win. loaded + = new routedeventhandler (win_loade D); win. Closed + = new eventhandler <windows. Controls. windowclosedeventargs> (win_closed);} void win_closed (Object sender, windows. Controls. windowclosedeventargs e) {If (! E. dialogresult. hasvalue) {radwindow. Alert ("the pop-up window is closed! ");} Else if (E. dialogresult. value) {string result = win. tag. tostring (); radwindow. alert ("click" Submit "to close it. The returned value is" + result);} else {radwindow. alert ("click" cancel "to close! ") ;}} Void win_loaded (Object sender, routedeventargs e) {radwindow. Alert (" the pop-up window is loaded! ");} Void forminput_unloaded (Object sender, routedeventargs e) {If (win! = NULL) {win. close (); win = NULL ;}} private void btnreg_click (Object sender, routedeventargs e) {# Pass parameters to the tag string param_id = "ID" in the pop-up window "; if (dicpars. containskey (param_id) {dicpars. remove (param_id);} dicpars. add (param_id, 1); win. tag = dicpars; # endregion win. showdialog ();}}}

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.