
几乎所有的业务系统都有d出窗口,典型场景有二种 :
1、简单的d出一个对话框显示信息,比如下面这样:
这个很简单,代码示例如下:
DialogParameters pars = new DialogParameters(); |
pars.header = "信息"; |
pars.Content = "Hello World"; |
radwindow.Alert(pars); |
2、点击某条记录的“编辑”按钮,传入ID参数,d出一个窗口,编辑保存后,将 *** 作结果返回给父窗口
这种场景下,要求:
a)d出窗口能接受到父窗口传过来的参数
b)d出窗口关闭时,父窗口要能区分出是通过什么 *** 作关闭的(比如:是直接点击右上角的X按钮关的,还是点击“提交”按钮关的,或是点击“取消”按钮关的)
c)d出窗关闭后,父窗口要能知道 *** 作结果
示例代码如下:
d出窗口Xaml部分:
01 | <telerik:radwindow x:Class="Telerik.Sample.PopWinUserReg" |
02 | xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
03 | xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
04 | xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
05 | xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
06 | xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" |
07 | mc:Ignorable="d" |
08 | d:DesignHeight="480" d:DesignWIDth="640" windowstartupLocation="CenterScreen" header="会员注册" padding="10" WIDth="640" Height="300" ResizeMode="noresize"> |
09 | |
10 | <GrID x:name="LayoutRoot" Background="White"> |
11 | <GrID.RowDeFinitions> |
12 | <RowDeFinition Height="30" /> |
13 | <RowDeFinition Height="30" /> |
14 | <RowDeFinition Height="30" /> |
15 | <RowDeFinition Height="30" /> |
16 | <RowDeFinition Height="30" /> |
17 | <RowDeFinition Height="30" /> |
18 | <RowDeFinition Height="30" /> |
19 | <RowDeFinition Height="auto" MinHeight="10" /> |
20 | <RowDeFinition Height="30" /> |
21 | </GrID.RowDeFinitions> |
22 | <GrID.ColumnDeFinitions> |
23 | <ColumnDeFinition WIDth="100" /> |
24 | <ColumnDeFinition WIDth="*" /> |
25 | </GrID.ColumnDeFinitions> |
26 | |
27 | <TextBlock VerticalAlignment="Center" TextAlignment="Right">用户名:</TextBlock> |
28 | <telerik:RadMaskedTextBox GrID.Column="1" GrID.Row="0" name="txtUsername" VerticalAlignment="Center" Mask="aaaaaaaaaa" margin="0,10,0" /> |
29 | <TextBlock VerticalAlignment="Center" TextAlignment="Right" GrID.Row="1">密码:</TextBlock> |
30 | <telerik:RadMaskedTextBox GrID.Column="1" GrID.Row="1" name="txtPassWord" VerticalAlignment="Center" margin="0,0" /> |
31 | <TextBlock VerticalAlignment="Center" TextAlignment="Right" GrID.Row="2">重复密码:</TextBlock> |
32 | <telerik:RadMaskedTextBox GrID.Column="1" GrID.Row="2" name="txtPassWord2" VerticalAlignment="Center" margin="0,0" /> |
33 | <TextBlock VerticalAlignment="Center" TextAlignment="Right" GrID.Row="3">生日:</TextBlock> |
34 | <telerik:RadMaskedTextBox GrID.Column="1" GrID.Row="3" name="txtBirthday" VerticalAlignment="Center" margin="0,0" /> |
35 | <TextBlock VerticalAlignment="Center" TextAlignment="Right" GrID.Row="4">电子邮件:</TextBlock> |
36 | <telerik:RadMaskedTextBox GrID.Column="1" GrID.Row="4" name="txtEmail" VerticalAlignment="Center" margin="0,0" /> |
37 | <TextBlock VerticalAlignment="Center" TextAlignment="Right" GrID.Row="5">电话号码:</TextBlock> |
38 | <telerik:RadMaskedTextBox GrID.Column="1" GrID.Row="5" name="txtTel" VerticalAlignment="Center" margin="0,0" /> |
39 | <TextBlock VerticalAlignment="Center" TextAlignment="Right" GrID.Row="6">手机号码:</TextBlock> |
40 | <telerik:RadMaskedTextBox GrID.Column="1" GrID.Row="6" name="txtMobile" VerticalAlignment="Center" margin="0,0" /> |
41 | |
42 | <StackPanel GrID.Row="8" GrID.Column="1" OrIEntation="Horizontal" Height="22"> |
43 | <telerik:Radbutton Content="提 交" WIDth="70" name="btnsubmit" Click="btnsubmit_Click" /> |
44 | <telerik:Radbutton Content="取 消" WIDth="70" margin="10,0" name="btnCancel" Click="btnCancel_Click" /> |
45 | </StackPanel> |
46 | </GrID> |
47 | </telerik:radwindow> |
d出窗口Xaml.cs部分
01 | using System; |
02 | using System.Collections.Generic; |
03 | using System.windows; |
04 | using Telerik.windows.Controls; |
05 | |
06 | namespace Telerik.Sample |
07 | { |
08 | public partial class PopWinUserReg : radwindow |
09 | { |
10 | public PopWinUserReg() |
11 | { |
12 | InitializeComponent(); |
13 | this.Loaded += new RoutedEventHandler(PopWinUserReg_Loaded); |
14 | } |
15 | |
16 | voID PopWinUserReg_Loaded(object sender,RoutedEventArgs e) |
17 | { |
18 | Dictionary<string,Object> dicPars = this.Tag as Dictionary<string,object>; |
19 | if (dicPars != null) |
20 | { |
21 | string ID = dicPars["ID"].ToString(); |
22 | radwindow.Alert("传入参数为:" + ID); |
23 | } |
24 | } |
25 | |
26 | private voID btnCancel_Click(object sender,RoutedEventArgs e) |
27 | { |
28 | this.DialogResult = false; |
29 | this.Close(); |
30 | } |
31 | |
32 | private voID btnsubmit_Click(object sender,RoutedEventArgs e) |
33 | { |
34 | this.DialogResult = true; |
35 | this.Tag = "回传给父窗口的值在这里!"; |
36 | this.Close(); |
37 | } |
38 | } |
39 | } |
父窗口Xaml.cs部分:
01 | using System; |
02 | using System.Collections; |
03 | using System.Collections.Generic; |
04 | using System.linq; |
05 | using System.Net; |
06 | using System.windows; |
07 | using System.windows.Controls; |
08 | using System.windows.documents; |
09 | using System.windows.input; |
10 | using System.windows.Media; |
11 | using System.windows.Media.Animation; |
12 | using System.windows.Shapes; |
13 | using Telerik.windows.Controls; |
14 | |
15 | namespace Telerik.Sample |
16 | { |
17 | public partial class Forminput : UserControl |
18 | { |
19 | PopWinUserReg win=null; |
20 | Dictionary<string,Object> dicPars = new Dictionary<string,object>(); |
21 | |
22 | public Forminput() |
23 | { |
24 | InitializeComponent(); |
25 | |
26 | this.Loaded += new RoutedEventHandler(Forminput_Loaded); |
27 | this.Unloaded += new RoutedEventHandler(Forminput_Unloaded); |
28 | } |
29 | |
30 | voID Forminput_Loaded(object sender,RoutedEventArgs e) |
31 | { |
32 | win = new PopWinUserReg(); |
33 | win.Loaded += new RoutedEventHandler(win_Loaded); |
34 | win.Closed += new EventHandler<windows.Controls.WindowClosedEventArgs>(win_Closed); |
35 | } |
36 | |
37 | voID win_Closed(object sender,windows.Controls.WindowClosedEventArgs e) |
38 | { |
39 | if (!e.DialogResult.HasValue) |
40 | { |
41 | radwindow.Alert("直接关闭了d出窗口!"); |
42 | } |
43 | else if (e.DialogResult.Value) |
44 | { |
45 | string result = win.Tag.ToString(); |
46 | radwindow.Alert("点击“提交”关闭的,传回来的值为:" + result); |
47 | } |
48 | else |
49 | { |
50 | radwindow.Alert("点击“取消”关闭的!"); |
51 | } |
52 | |
53 | |
54 | } |
55 | |
56 | voID win_Loaded(object sender,RoutedEventArgs e) |
57 | { |
58 | radwindow.Alert("d出窗口加载完成!"); |
59 | } |
60 | |
61 | voID Forminput_Unloaded(object sender,RoutedEventArgs e) |
62 | { |
63 | if (win != null) |
64 | { |
65 | win.Close(); |
66 | win = null; |
67 | } |
68 | } |
69 | |
70 | private voID btnReg_Click(object sender,RoutedEventArgs e) |
71 | { |
72 | #region 传参数到d出窗口的Tag |
73 | string ParaM_ID = "ID"; |
74 | if (dicPars.ContainsKey(ParaM_ID)) |
75 | { |
76 | dicPars.Remove(ParaM_ID); |
77 | } |
78 | dicPars.Add(ParaM_ID,1); |
79 | win.Tag = dicPars; |
80 | #endregion |
81 | win.ShowDialog(); |
82 | } |
83 | } |
84 | } |
出处: http://yjmyzz.cnblogs.com 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。 总结
以上是内存溢出为你收集整理的Silverlight Telerik控件学习:d出窗口RadWindow全部内容,希望文章能够帮你解决Silverlight Telerik控件学习:d出窗口RadWindow所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)