WPF网格与Stackpanel [英] WPF Grid vs Stackpanel
问题描述
对于WPF / Silverlight布局,使用具有大量行和列的网格或大量Stackpanels是更好的选择吗?
解决方案如果你需要水平和垂直排列的东西,你应该使用Grid。使用StackPanel创建一行或一列的东西,当这些东西不需要与其他东西对齐时。
然而,不要只限于这两个选项。特别是,看看DockPanel。它比StackPanel稍微复杂一些,但它的标记不像Grid那么混乱。这里有一篇关于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屋!