一:截图
二:XAML代码
<Window x:Class="wpf练习.登录窗体" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="登录窗体" Height="200" Width="300"> <Grid> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition></ColumnDefinition> <ColumnDefinition></ColumnDefinition> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <TextBlock Text="用户名:" Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock> <TextBox Name="txtName" Text="红马車" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Grid.Row="0" Grid.Column="0" Margin="10" Grid.ColumnSpan="2" Width="175" HorizontalAlignment="Right"></TextBox> <TextBlock Text="密码:" Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Center" ></TextBlock> <PasswordBox Name="pwdInfo" Grid.Row="1" Grid.Column="0" Margin="10" Grid.ColumnSpan="2" Width="175" HorizontalAlignment="Right"></PasswordBox> <Button Name="btnLogin" Content="登录" Grid.Column="0" Grid.Row="2" Margin="10" Width="75"></Button> <Button Name="btnCancel" Content="取消" Grid.Column="2" Grid.Row="2" Margin="10" Width="75"></Button> </Grid> </Grid> </Window>