惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 叶小钗
云风的 BLOG
云风的 BLOG
G
Google Developers Blog
S
SegmentFault 最新的问题
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
美团技术团队
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
DataBreaches.Net
F
Fortinet All Blogs
TaoSecurity Blog
TaoSecurity Blog
D
Docker
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
宝玉的分享
宝玉的分享
腾讯CDC
Google Online Security Blog
Google Online Security Blog
Recorded Future
Recorded Future
T
The Exploit Database - CXSecurity.com
T
The Blog of Author Tim Ferriss
V
V2EX
S
Securelist
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
C
CERT Recently Published Vulnerability Notes
A
Arctic Wolf
Scott Helme
Scott Helme
L
LINUX DO - 热门话题
Y
Y Combinator Blog
P
Proofpoint News Feed
T
Tor Project blog
AWS News Blog
AWS News Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
The Last Watchdog
The Last Watchdog
博客园 - 聂微东
T
Threat Research - Cisco Blogs
B
Blog
Attack and Defense Labs
Attack and Defense Labs
L
Lohrmann on Cybersecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
N
News and Events Feed by Topic
博客园 - 司徒正美
H
Help Net Security
C
Cisco Blogs
C
Check Point Blog
S
Secure Thoughts

博客园 - AlexCube

ILSpy --- baml反编译错误解决方案 Privacy Policy 小工具 --- 英文单词查询 Wave Generator 2.0.1 SQL Server Full Text Search WPF TreeView View Model 使用dynamic 类型动态调用方法 Silverlight, WCF, Windows Authentication - AlexCube .Net 程序运行方式 如何查看Load Assembly 错误日志 License 收集 VLAN WPF 开源程序 .Net 中通过Reflection获得List成员类型 - AlexCube - 博客园 SQL Server 获取字符串的长度 SQL Server 查看 SQL 语句执行时间 WPF RichTextBox 控件 如何获取正确的 AJAX Control Toolkit 客户端控件脚本 用户控件 vs 自定义控件
WPF Layout
AlexCube · 2010-03-11 · via 博客园 - AlexCube

常用的有5种 Layout panels:

  • Grid Panel
  • Stack Panel
  • Dock Panel
  • Wrap Panel
  • Canvas Panel

技巧:

  • 避免使用固定位置 - 多使用Alignment 和 Margin 属性
  • 不要使用固定大小 - 尽可能将Width和Height设置为Auto
  • 不要滥用Canvas Panel, 他只能用于矢量图片
  • 在对话框中使用StackPanel 布置 按钮控件Buttons
  • Use a GridPanel to layout a static data entry form. Create a Auto sized column for the labels and a Star sized column for the TextBoxes.
  • Use an ItemControl with a grid panel in a DataTemplate to layout dynamic key value lists. Use the SharedSize feature to synchronize the label widths.

Vertical 和 Horizontal Alignment 属性

v2_alignment

Margin 和 Padding

用于为控件预留空间

  • Margin - 控件外部预留空间
  • Padding - 控件内部预留空间
  • 外面控件的Padding相当于内部控件的Margin

padding_margin

Height 和 Width 属性

不推荐使用,可以用于设置控件的固定大小。最好用MinHeight,MaxHeight,MinWidth 和MaxWidth属性定义可接受的大小范围

Overflow Handling

Clipping

Layout panels typically clip those parts of child elements that overlap the border of the panel. This behavior can be controlled by setting the ClipToBounds property to true or false.

cliptobounds

Scrolling

When the content is too big to fit the available size, you can wrap it into a ScrollViewer. The ScrollViewer uses two scroll bars to choose the visible area.

The visibility of the scrollbars can be controlled by the vertical and horizontal ScrollbarVisibility properties.

<ScrollViewer>
    <StackPanel>
        <Button Content="First Item" />
        <Button Content="Second Item" />
        <Button Content="Third Item" />
    </StackPanel>
</ScrollViewer>

From: http://www.wpftutorial.net/LayoutProperties.html