当前位置:网站首页>WPF 界面布局必知基础
WPF 界面布局必知基础
2022-07-29 06:20:00 【济南医疗小程序状元】
WPF 界面布局必知基础
<Window x:Class="WpfApp1728.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1728"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<!--<DockPanel>
<Button Content="top Button" DockPanel.Dock="Top" Height="135" Width="370" ></Button>
</DockPanel>-->
<Grid ShowGridLines="True">
<Grid.RowDefinitions>
<!--行定义 3行4列的定义 -->
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<!--列定义-->
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Content="Left Top Button" />
<!--1 指定行 Grid.Row="2" 2 指定列 Grid.Column="3" 控制按钮的位置。把附加属性用好,就基本够用了。-->
<Button Content="Right Bottom Top Button" Grid.Row="2" Grid.Column="3" />
</Grid>
</Window>
<Window x:Class="WpfApp1728.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1728"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<!--<DockPanel>
<Button Content="top Button" DockPanel.Dock="Top" Height="135" Width="370" ></Button>
</DockPanel>-->
<Grid ShowGridLines="True">
<Grid.RowDefinitions>
<!--行定义 3行4列的定义 -->
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<!--列定义-->
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Content="Left Top Button" />
<!--1 指定行 Grid.Row="2" 2 指定列 Grid.Column="3" 控制按钮的位置。把附加属性用好,就基本够用了。-->
<Button Content="Right Bottom Top Button" Grid.Row="2" Grid.Column="3" />
<!--跨列设计属性 Grid.ColumnSpan-->
<Button Content="ColumnSpan Button" Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="2" />
<!--跨行属性 Grid.RowSpan-->
<Button Content="RowSpan Button" Grid.Row="0" Grid.Column="1" Grid.RowSpan="3"/>
</Grid>
</Window>
效果

最小宽度设置,最小压缩设置也叫做。
<Button Content="Left Top Button" MinWidth="80" />
最小宽度
<!--列定义-->
<ColumnDefinition MinWidth="100" Width="*"/>
效果

自适应(到跟文字内容同样的高度) auto代码以及效果
<!--行定义 3行4列的定义 -->
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>

内外边距

<Button Content="Right Bottom Top Button" Grid.Row="2" Margin="10,10,10,10" Grid.Column="3" />
外边距效果
边栏推荐
- Record - step on the pit - real-time data warehouse development - doris/pg/flink
- Flink实时仓库-DWD层(处理复杂数据-流和表的装换处理)模板代码
- vim文本编辑器的一些使用小技巧
- 基于C语言实现图书借阅管理系统
- Salesforce中过滤器Filter使用的相对日期
- The difference between pairs and ipairs
- 模拟卷Leetcode【普通】150. 逆波兰表达式求值
- 太空射击第17课: Game Over (結束)
- Apisik health check test
- Talk about tcp/ip protocol? And the role of each layer?
猜你喜欢

做开发4年13K,想转行自动化测试,薪资还能涨吗···

城市花样精~侬好!DESIGN#可视化电台即将开播

Actual combat! Talk about how to solve the deep paging problem of MySQL

Revolution of game assets

Windows 上 php 7.4 连接 oracle 配置

图像加噪声与矩阵求逆

10 frequently asked JVM questions in interviews

vim文本编辑器的一些使用小技巧

Teacher wangshuyao's notes on operations research course 10 linear programming and simplex method (discussion on detection number and degradation)

MySQL: what happens in the bufferpool when you crud? Ten pictures can make it clear
随机推荐
Teacher wangshuyao's notes on operations research 03 KKT theorem
约瑟夫环问题
Excerpts from good essays
图像加噪声与矩阵求逆
Unity free element special effect recommendation
[C language brush leetcode] 67. binary sum (E)
Analog volume leetcode [normal] 093. Restore IP address
JVM之垃圾回收机制(GC)
说一下 TCP/IP 协议?以及每层的作用?
Flink实时仓库-DWD层(交易域-加购维度退化处理)模板代码
vim文本编辑器的一些使用小技巧
Jetpack Compose 中的键盘处理
Teacher wangshuyao's notes on operations research 05 linear programming and simplex method (concept, modeling, standard type)
Can MySQL export tables regularly?
聊天机器人有何用处?有何类型?看完这些就明白了!
leetcode-592:分数加减运算
数组的子集能否累加出K
建木持续集成平台v2.5.2发布
谷歌零碎笔记之JWT(草稿)
二次元卡通渲染——进阶技巧