当前位置:网站首页>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" />
外边距效果
边栏推荐
- 【C语言刷LeetCode】67. 二进制求和(E)
- Teacher wangshuyao wrote the notes of operations research course 00 in the front
- Pytorch多GPU条件下DDP集群分布训练实现(简述-从无到有)
- 数据库多表查询 联合查询 增删改查
- Some tips of vim text editor
- leetcode-592:分数加减运算
- DM data guard cluster setup
- JVM之垃圾回收机制(GC)
- Flink实时仓库-DWD层(kafka-关联mysql的lookup join)模板代码
- Teacher wangshuyao's notes on operations research 06 linear programming and simplex method (geometric significance)
猜你喜欢
随机推荐
聊天机器人有何用处?有何类型?看完这些就明白了!
Simulation volume leetcode [normal] 061. rotating linked list
做开发4年13K,想转行自动化测试,薪资还能涨吗···
图像加噪声与矩阵求逆
【C语言刷LeetCode】67. 二进制求和(E)
Leetcode-1331: array ordinal conversion
Overview of database system
剑指 Offer II 115:重建序列
分享一些你代码更好的小建议,流畅编码提搞效率
Junda technology | applicable to "riyueyuan" brand ups wechat cloud monitoring card
竣达技术 | 适用于”日月元”品牌UPS微信云监控卡
DM data guard cluster setup
The core of openresty and cosocket
ECCV 2022 lightweight model frame Parc net press apple mobilevit code and paper Download
1172. 餐盘栈 有序列表+栈
Leetcode-592: fraction addition and subtraction
Unity探索地块通路设计分析 & 流程+代码具体实现
Teacher wangshuyao's notes on operations research 03 KKT theorem
IO stream - file - properties
Teacher wangshuyao's notes on operations research 01 guidance and introduction









