Welcome

首页 / 软件开发 / Silverlight / 一起学Windows Phone7开发(十三.十 Silverlight.Toolkit 控件)

一起学Windows Phone7开发(十三.十 Silverlight.Toolkit 控件)2010-11-07 博客园 小镇Silverlight.Toolkit 是Silverlight控件、部件和实用程序在普通Silverlight 以外发布的一个集合。是微软团队的一个产品,它快速为设计者和开发者增加新功能,并且提供社区帮助由贡献想法和错误报告塑造产品开发的一个有效的方法。它包含了超过26个新控件的完整的开源代码、单位测试、实例和文档、样式、布局和用户输入。但是这个集合在Phone7中并没有完全被支持。

要使用这个集合需要下载这个包:

http://silverlight.codeplex.com/releases/view/43528

1.WrapPanel:这个面板控件主要是通过Orientation属性设置包含在控件是的元素从左至右或从上至下依次安排位置,当元素超过该控件边缘时,它们将会被自动转至下一行或列。此控件一般用于文本布局、拾色器、图片等。需要加载System.Windows.Controls.Toolkit.dll

Xaml:

<controlsToolkit:WrapPanel x:Name="wp1" Margin="15,0,15,201" Grid.Row="1" Width="350" Height="300" VerticalAlignment="Bottom" Orientation="Horizontal" />

源代码:

for (int i = 0; i < 30; i++)
{
wp1.Children.Add(new Rectangle() { Height = 50, Width = 50, Fill = new SolidColorBrush(Colors.Yellow) });
wp1.Children.Add(new Rectangle() { Height = 50, Width = 50, Fill = new SolidColorBrush(Colors.Purple) });
wp1.Children.Add(new Rectangle() { Height = 50, Width = 50, Fill = new SolidColorBrush(Colors.Red) });
wp1.Children.Add(new Rectangle() { Height = 50, Width = 50, Fill = new SolidColorBrush(Colors.Black) });
wp1.Children.Add(new Rectangle() { Height = 50, Width = 50, Fill = new SolidColorBrush(Colors.Brown) });
wp1.Children.Add(new Rectangle() { Height = 50, Width = 50, Fill = new SolidColorBrush(Colors.Cyan) });
wp1.Children.Add(new Rectangle() { Height = 50, Width = 50, Fill = new SolidColorBrush(Colors.DarkGray) });
wp1.Children.Add(new Rectangle() { Height = 50, Width = 50, Fill = new SolidColorBrush(Colors.Green) });
wp1.Children.Add(new Rectangle() { Height = 50, Width = 50, Fill = new SolidColorBrush(Colors.Magenta) });

}