稳扎稳打Silverlight(35)

返回“稳扎稳打Silverlight 3.0系列文章索引”

稳扎稳打Silverlight(35) - 3.0控件之ChildWindow,SaveFileDialog,HeaderedItemsControl,VirtualizingStackPanel

介绍

Silverlight 3.0 控件一览:

ChildWindow - 用于在父窗体前弹出一个的子窗体

SaveFileDialog - 用户发起的保存文件对话框(OpenFileDialog - 打开文件对话框)

HeaderedItemsControl - 呈现标题和集合数据的控件

VirtualizingStackPanel - 虚拟化的 StackPanel(即仅生成需要显示的 UI 元素。当绑定了大量数据,而某时仅显示其中一小部分的时候,使用此控件则可大幅提高呈现效率) 

在线DEMO

http://www.cnblogs.com/webabcd/archive/2009/08/04/1538238.html

示例

1、演示 ChildWindow 的应用

ChildWindowDemo.xaml

<navigation:Page x:Class="Silverlight30.Control.ChildWindowDemo"
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"
mc:Ignorable="d"
xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
d:DesignWidth="640" d:DesignHeight="480"
Title="ChildWindowDemo Page">
<Grid x:Name="LayoutRoot">
<StackPanel>

<Button x:Name="btnChildWindow" Content="Show ChildWindow" Click="btnChildWindow_Click" />
<Button x:Name="btnCustomChildWindow" Content="Show CustomChildWindow" Click="btnCustomChildWindow_Click" />

<TextBlock x:Name="lblResult" />

</StackPanel>
</Grid>
</navigation:Page>

ChildWindowDemo.xaml.cs

using System;
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 System.Windows.Navigation;

namespace Silverlight30.Control
{
public partial class ChildWindowDemo : Page
{
public ChildWindowDemo()
{
InitializeComponent();
}

private void btnChildWindow_Click(object sender, RoutedEventArgs e)
{
/**//*
* ChildWindow - 在父窗体前显示的子窗体
*     Title - 子窗体的标题
*     Content - 子窗体的内容
*     HasCloseButton - 子窗体上是否要有关闭按钮(右上角的 ×)
*     OverlayBrush - 子窗体打开后,覆盖在父窗体上的 Brush
*     OverlayOpacity - 子窗体打开后,覆盖在父窗体上的 Brush 的不透明度
*     Width - 子窗体的宽
*     Height - 子窗体的高
*     Closed事件 - 子窗体关闭后所触发的事件
*     Show() - 打开(显示)子窗体
*/

ChildWindow child = new ChildWindow();
child.Title = "标题";
child.Content = "内容";
child.HasCloseButton = true;
child.OverlayBrush = new SolidColorBrush(Colors.Red);
child.OverlayOpacity = 0.3;
child.Width = 320;
child.Height = 240;

child.Show();
}

void child_Closed(object sender, EventArgs e)
{
/**//*
* ChildWindow.DialogResult - 子窗体传递回来的一个 bool? 值(可以用来描述在子窗体中是单击了“确定”按钮还是“取消”按钮)
* ChildWindow.DataContext - 子窗体传递回来的数据上下文
*/

CustomChildWindow child = sender as CustomChildWindow;
MessageBox.Show(string.Format("DialogResult:{0}; DataContext:{1}", child.DialogResult, child.DataContext));
}

private void btnCustomChildWindow_Click(object sender, RoutedEventArgs e)
{
CustomChildWindow child = new CustomChildWindow();
child.Closed += new EventHandler(child_Closed);
child.Show();
}
}
}

时间: 2024-08-30 08:56:33

稳扎稳打Silverlight(35)的相关文章

稳扎稳打Silverlight 3.0系列文章索引

相关文章:稳扎稳打Silverlight 2.0系列文章索引 在线DEMO http://www.cnblogs.com/webabcd/archive/2009/08/04/1538238.html 1.稳扎稳打Silverlight(33) - 3.0控件之AutoCompleteBox,DataPager 介绍 Silverlight 3.0 控件一览: AutoCompleteBox - 自动完成控件.当用户输入部分信息后,此控件可以基于指定的过滤算法在一个下拉框中陈列出匹配项 Data

稳扎稳打Silverlight(4)

稳扎稳打Silverlight(4) - 2.0控件之DataGrid,DatePicker,Grid,GridSplitter,HyperlinkButton,Image 在线DEMO http://www.cnblogs.com/webabcd/archive/2008/10/09/1307486.html 示例 1.DataGrid.xaml <UserControl xmlns:data="clr-namespace:System.Windows.Controls;assembly

稳扎稳打Silverlight(36)

返回"稳扎稳打Silverlight 3.0系列文章索引" 稳扎稳打Silverlight(36) - 3.0控件之TreeView,ListBox增强,DataGrid增强,MediaElement增强 介绍 Silverlight 3.0 控件一览: TreeView - 树控件 ListBox - 改进:支持多选 DataGrid - 改进:结合 PagedCollectionView 实现数据分组, 增加了一些编辑数据的相关事件, 结合 DataAnnotations 实现数据

稳扎稳打Silverlight(51)

稳扎稳打Silverlight(51) - 4.0绑定之数据验证IDataErrorInfo,INotifyDataErrorInfo 介绍 Silverlight 4.0 数据验证: * IDataErrorInfo - 对数据实体类提供自定义验证支持..NET Framework 也有此接口,可以方便移植 * INotifyDataErrorInfo - 对数据实体类提供自定义验证支持,比 IDataErrorInfo 功能更强大.INotifyDataErrorInfo 支持异步验证,这就

稳扎稳打Silverlight(47)

稳扎稳打Silverlight(47) - 4.0UI之操作剪切板,隐式样式,CompositeTransform,拖放外部文件到程序中 介绍 Silverlight 4.0 用户界面(UI)相关: * 操作剪切板 - 支持获取或设置剪切板中的文本信息 * 隐式样式(Implicit Style) - 将某种样式应用到某种类型的所有元素,即全局样式 * CompositeTransform - 将多种转换方式合而为一 * 拖动(Drag)外部文件,并将其放到(Drop) Silverlight

稳扎稳打Silverlight(46)

稳扎稳打Silverlight(46) - 4.0UI之FlowDirection,TextTrimming,响应鼠标滚轮事件,响应鼠标右键事件,全屏的新特性 介绍 Silverlight 4.0 用户界面(UI)相关: * FlowDirection - 指定文本或界面元素在它们的父元素中的流动方向 * TextTrimming - 文字溢出时的显示方式 * 响应鼠标的滚轮事件 * 响应鼠标的右键事件 * 全屏的新特性 - 当其他程序获得焦点时,是否退出全屏模式 在线DEMO http://w

稳扎稳打Silverlight(45)

稳扎稳打Silverlight(45) - 4.0浏览器外运行(Out Of Browser)之被信任的应用程序(Trusted Application) 介绍 Silverlight 4.0 OOB 之 被信任的应用程序: * 概述 * 访问本地文件系统 * 调用 COM 接口 * 自定义窗口样式和行为 在线DEMO http://www.cnblogs.com/webabcd/archive/2010/08/09/1795417.html 示例 1.关于"被信任的应用程序"的简要概

稳扎稳打Silverlight(44)

稳扎稳打Silverlight(44) - 4.0浏览器外运行(Out Of Browser)之OOB的增强及其新增的NotificationWindow 介绍 Silverlight 4.0 OOB 模式的新特性: * 新增了 Closing 事件 * 实现程序在 OOB 模式下的自动更新 * NotificationWindow - 在 OOB 模式下显示通知窗口,也就是 toast * 实现自定义的 NotificationWindow 在线DEMO http://www.cnblogs.

稳扎稳打Silverlight(41)

返回"稳扎稳打Silverlight 3.0系列文章索引" 稳扎稳打Silverlight(41) - 3.0Tip/Trick之GPU加速,Out-Of-Browser,应用程序库缓存,合并ResourceDictionary,应用程序扩展服务,Silverlight插件对象 介绍 Silverlight 3.0 提示和技巧系列 GPU 加速 - 对 GPU 加速的支持 Out-Of-Browser -浏览器外运行,即支持脱离浏览器运行 应用程序库缓存 - 将 dll(zip) 缓存