Silverlight Telerik控件学习:弹出窗口RadWindow
来源:互联网 发布:win7 kali linux双系统 编辑:程序博客网 时间:2024/09/21 09:29
Silverlight Telerik控件学习:弹出窗口RadWindow
几乎所有的业务系统都有弹出窗口,典型场景有二种 :
1、简单的弹出一个对话框显示信息,比如下面这样:
这个很简单,代码示例如下:
DialogParameters pars =
new
DialogParameters();
pars.Header =
"信息"
;
pars.Content =
"Hello World"
;
RadWindow.Alert(pars);
2、点击某条记录的“编辑”按钮,传入ID参数,弹出一个窗口,编辑保存后,将操作结果返回给父窗口
这种场景下,要求:
a)弹出窗口能接受到父窗口传过来的参数
b)弹出窗口关闭时,父窗口要能区分出是通过什么操作关闭的(比如:是直接点击右上角的X按钮关的,还是点击“提交”按钮关的,或是点击“取消”按钮关的)
c)弹出窗关闭后,父窗口要能知道操作结果
示例代码如下:
弹出窗口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,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,10,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,10,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,10,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,10,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,10,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,10,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,0,0"
Name=
"btnCancel"
Click=
"btnCancel_Click"
/>
45
</StackPanel>
46
</Grid>
47
</telerik:RadWindow>
弹出窗口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(
"直接关闭了弹出窗口!"
);
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(
"弹出窗口加载完成!"
);
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 传参数到弹出窗口的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
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
出处:http://yjmyzz.cnblogs.com
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
- Silverlight Telerik控件学习:弹出窗口RadWindow
- ArcGIS API for Silverlight 点击地图上的要素,弹出窗口(使用Telerik RadWindow)
- telerik - radwindow
- Silverlight Telerik控件学习:主题Theme切换
- Silverlight Telerik控件学习:GridView双向绑定
- telerik控件学习资料
- Telerik Silverlight CoverFlow 控件- CenterOffsetY, 图片间距
- Telerik Silverlight 之Charting控件的使用
- 用 RadWindow 做主窗口
- Silverlight - 浏览器弹出窗口
- Silverlight中实现类似Telerik的TileView控件效果
- silverlight telerik RadGridView 列头显示其他控件
- Silverlight窗口控件说明
- Easy RadControl 之 RadWindow(Silverlight)
- Telerik公司的RadControls控件学习笔记
- Telerik ajax 控件学习笔记 - Ajax
- DIV弹出窗口控件
- telerik学习
- 爱,从心而来,无法强求
- jQuery最佳实践
- Ruby on rails开发从头来(四十一)- ActiveRecord基础(存储结构化数据)
- Ruby on rails开发从头来(四十)- ActiveRecord基础(Boolean属性)
- Ruby on rails开发从头来(三十九)- ActiveRecord基础(访问属性)
- Silverlight Telerik控件学习:弹出窗口RadWindow
- ie8 ctrl+f 失效处理
- 摇一摇 晃动效果 未能出现效果
- Ruby on rails开发从头来(三十八)- ActiveRecord基础(列和属性)
- 动态数组(栈)的实现实例
- 移植OpenSSH到arm手记
- Ruby on rails开发从头来(三十七)- ActiveRecord基础
- Camera 图像处理原理分析篇 一
- 设计模式之(十五)职责链Chain of Responsibility