Silverlight.Toolkit 是Silverlight控制項、組件和公用程式在普通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) });
}