WPF中Grid布局XMAl<Grid Width="200" Height="100" >
<Window x:Class="wpfyonghukongjian.login"
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:wpfyonghukongjian"
mc:Ignorable="d"
Title="login" Height="150" Width="300">
<Grid>
<!--定义了两列-->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="100*"/>
</Grid.ColumnDefinitions>
<!--定义了四行-->
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" TextAlignment="Right" Text="用户名:" Name="UserName" />
<!--第一行第一列-->
<TextBlock Grid.Row="1" Grid.Column="0" TextAlignment="Right" Text="密码:" Name="pass"/>
<TextBlock Grid.Row="2" Grid.Column="0" TextAlignment="Right" Text="确认密码:" Name="repass"/>
<Button Grid.Row="3" Grid.ColumnSpan="2" Height="23" Width="100" Content="确认" Click="Button_Click" Name="btn"/>
<!--Grid.ColumnSpan="2":合并单元格-->
<TextBox Name="TxtBoxName" Grid.Row="0" Grid.Column="1" Text="" Width="200"/>
<!--第一行第二列-->
<PasswordBox Name="pass1" Grid.Row="1" Grid.Column="1" Width="200"/>
<!--密码框-->
<PasswordBox Name="pass2" Grid.Row="2" Grid.Column="1" Width="200"/>
</Grid>
</Window>
效果如图所示