Border 控件

Border:在另一个对象的周围绘制边框、背景或同时绘制二者。

<Window x:Class="MaterialStorage.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <!--在这里给网格定义了三行一列 第一行高20 第三行高20 其余的自适应-->
        <Grid.RowDefinitions>
            <RowDefinition Height="20"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="20"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" ></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <Button Grid.Row="0">按钮1</Button>
        <!-- Border 被单独拿出来,用于为一些容器绘制边框-->
        <Border BorderThickness="3" BorderBrush="Black" Grid.Row="1">
            <StackPanel Background="LightGray" Width="200" Height="60">
                <TextBlock Text="AutoCompleteBox Control" Width="90"/>
            </StackPanel>
        </Border>
        <Button Grid.Row="2">按钮3</Button>
    </Grid>
</Window>

需要注意这里的黑色边框,他填满了整个第二行。

原文地址:https://www.cnblogs.com/zhuzhenyu/p/2937236.html