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

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

问题描述

对于 WPF/Silverlight 布局,使用具有大量行和列的 Grid 还是大量 Stackpanel 更好?

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

推荐答案

如果您需要水平和垂直排列的东西,您应该使用网格.当这些内容不需要与其他任何内容对齐时,使用 StackPanel 创建一行或一列内容.

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.

但是,不要将自己限制在这两个选项中.特别是,看看 DockPanel.它比 StackPanel 稍微复杂一些,但它的标记不像 Grid 那样混乱.这里有一篇关于 DockPanel 的好文章:

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:

在 Silverlight 2 中使用 DockPanel

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

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