WPF-使用面板控制内容布局,比较Canvas,WrapPanel,StackPanel,Grid,ScrollViewer
2013-10-14 13:01
603 查看
WPF-使用面板控制内容布局,比较Canvas,WrapPanel,StackPanel,Grid,ScrollViewer
分类: WPF2012-04-24 09:59 660人阅读 评论(0) 收藏 举报header
<window>作用月内只能放置一个元素,窗口的Content属性只能设置一个对象。使用面板控件。
Canvas:使用绝对定位,如果窗口的大小小于canvas面板,一部分内容会看不见,canvas中的项不能自动调整大小,在canvas内的控件指定左上角,用Canvas.Top和Canvas.Left属性。
WrapPanel:内容随窗口大小的变化而变化,内容按声明顺序逐个呈现,用ItemWidth和ItemHeight控制子项的默认尺寸。根据Orientation设置Vertical,Horizontal布局。
StackPanel:不会内容折行,内容会自动拉伸。根据Orientation设置Vertical,Horizontal布局。
Grid:划分为单元格,定义并配置列,定义并配置行,设置每个单元格内容。
Grid对象支持拆分器(splitter),允许用户调整网格类型中行或列的大小,每个科调整的单元格都会根据所包含的项进行重塑。添加拆分器,只需要定义<GridSplitter>控件,并使用附加语法指定要拆分的行或列。
[html] view plaincopy
<Grid.ColumnDefinitions>
<ColumnDefinition <span style="color:#ff0000;">Width="Auto"</span> />
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<span style="color:#ff0000;"><GridSplitter</span> Grid.Column="0" Width="5" Background="Gray"/>
<StackPanel Grid.Column="0" VerticalAlignment="Stretch">
<Label Name="lblSpellingInstructuins" FontSize="14" Margin="10,10,0,0">Spell Hints</Label>
<Expander Name="expanderSpelling" Header="try these">
<Label Name="lblSpellingHints" FontSize="12"/>
</Expander>
</StackPanel>
注意:支持拆分器的列的Width值为Auto。
ScrollViewer:内容自动滚动。
DockPanel: 将内容锁定在面板的某一侧(Top,Bottom,Left,Right),好处:在用户调整窗口大小时,每个元素仍然能连接到指定的面板边缘。
原文引用:http://blog.csdn.net/yuhaoyang1/article/details/7485989
相关文章推荐
- unity3d 生命槽的设置
- android setTag (int key, Object tag)抛出IllegalArgumentException的问题
- Android 下拉刷新框架实现
- Android -- 工程目录解释
- iOS 后台运行实现
- Pro Android学习笔记(四十):Fragment(5):适应不同屏幕或排版
- iOS图片拉伸技巧
- babyClock 1.0发布(Android2.2以上)
- ios 强制某个界面旋转成横屏
- Cocos2d瓦片地图的导入
- Unity3D 摄像机(Camera)属性详解
- iOS-解决"A valid provisioning profile for this executable was not found"
- Android 自定义View可拖动移动位置及边缘拉伸放大缩小
- Android的AlertDialog详解
- Android中按比例缩放图片以减少内存消耗 解决oom问题
- android下截屏
- HTML5 Web app开发工具Kendo UI Web教程:如何配置Kendo UI Calendar
- Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.E
- Android应用如何监听自己是否被卸载
- 为什么导入android项目后 ,找不到类库