WPF网格与Stackpanel [英] WPF Grid vs Stackpanel

查看:134
本文介绍了WPF网格与Stackpanel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于WPF / Silverlight布局,使用具有大量行和列的网格或大量Stackpanels是更好的选择吗?

解决方案

如果你需要水平和垂直排列的东西,你应该使用Grid。使用StackPanel创建一行或一列的东西,当这些东西不需要与其他东西对齐时。



然而,不要只限于这两个选项。特别是,看看DockPanel。它比StackPanel稍微复杂一些,但它的标记不像Grid那么混乱。这里有一篇关于DockPanel的好文章:

在Silverlight 2中使用DockPanel


For WPF/Silverlight layout, is it better to use a Grid with lots of rows and columns, or tons of Stackpanels?

解决方案

You should use a Grid if you need things to line up horizontally and vertically. Use a StackPanel to create a row or column of things when those things don't need to line up with anything else.

However, don't limit yourself to those two options. In particular, have a look at the DockPanel. It's slightly more complex than a StackPanel, but its markup isn't as cluttered as the Grid. Here's a good article on the DockPanel:

Using the DockPanel in Silverlight 2

这篇关于WPF网格与Stackpanel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆