WPF之GroupBox控件实现一个登录页面

GroupBox控件即组合控件,该是将一个功能中所需的控件组合再一起的显示的控件,该控件周边会有边界及标题。

效果

代码

    <StackPanel Margin="10"
                VerticalAlignment="Center">
        <GroupBox Width="300"
                  Header="登录"
                  Height="200">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="50" />
                    <RowDefinition Height="50"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <StackPanel Grid.Row="0"
                            Orientation="Horizontal">
                    <Label Content="账号"
                           Width="60"
                           HorizontalContentAlignment="Center"
                           VerticalContentAlignment="Center" />
                    <TextBox Height="28"
                             Width="220" />
                </StackPanel>
                <StackPanel Grid.Row="1"
                            Orientation="Horizontal">
                    <Label Content="密码"
                           Width="60"
                           HorizontalContentAlignment="Center"
                           VerticalContentAlignment="Center" />
                    <PasswordBox Height="28"
                             Width="220" />
                </StackPanel>
                <Button Grid.Row="2" Width="90" Height="28" Content="登录"/>
            </Grid>

        </GroupBox>
    </StackPanel>
posted @ 2022-07-08 10:53  殷慈航  阅读(190)  评论(0编辑  收藏  举报