`

WP7 silverlight toolkit 学习之 WrapPanel 使用

    博客分类:
  • WP7
阅读更多

xaml:

<toolkit:WrapPanel Height="300"
HorizontalAlignment="Left"
Margin="58,152,0,0"
Name="wrp"
VerticalAlignment="Top"
Width="350"
Orientation="Horizontal"/>
</Grid>

这是前台页面,控件很简单,也可以归类到面板类,这个控件会自动换行,不会层叠,你可以设置方向,垂直排列,也可以横排列

cs:

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
{
for (int i = 0; i < 50; i++)
{
wrp.Children.Add(new Rectangle() { Width=50,Height=50,Fill=new SolidColorBrush(Colors.Yellow)});
wrp.Children.Add(new Rectangle() { Width = 50, Height = 50, Fill = new SolidColorBrush(Colors.Red) });
wrp.Children.Add(new Rectangle() { Width = 50, Height = 50, Fill = new SolidColorBrush(Colors.Blue) });
wrp.Children.Add(new Rectangle() { Width = 50, Height = 50, Fill = new SolidColorBrush(Colors.Green) });
wrp.Children.Add(new Rectangle() { Width = 50, Height = 50, Fill = new SolidColorBrush(Colors.White) });
}
}

你试下效果就知道了哦

分享到:
评论
发表评论

文章已被作者锁定,不允许评论。

相关推荐

Global site tag (gtag.js) - Google Analytics