在顶部的网格内定位停靠面板内容

Positioning dockpanel content within a grid at the top

我正在尝试放置一种由矩形制成的边框,并在其中放置一个标签和一些项目符号装饰器。我需要将它们放在网格的特定行和列中以及顶部。

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>                
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="150" />                    
    </Grid.ColumnDefinitions>

<!-- other controls in grid -->

<DockPanel Grid.Row="1" Grid.Column="1">
    <Grid>
        <Rectangle Width="120" Height="80" Fill="LightYellow" Stroke="Orange" StrokeThickness="2" RadiusX="8" RadiusY="8"/>
        <Rectangle Width="120" Height="80" Fill="Transparent" Stroke="Orange" StrokeThickness="2" RadiusX="8" RadiusY="8">
            <Rectangle.Effect>
                <DropShadowEffect ShadowDepth="0" BlurRadius="15" Color="Orange"/>
            </Rectangle.Effect>
            <Rectangle.Clip>
                <RectangleGeometry Rect="0,0,400,80" RadiusX="8" RadiusY="8"/>
            </Rectangle.Clip>
        </Rectangle>
        <Grid>
            <Label Content="Legend:"/>
            <BulletDecorator Margin="5,20,0,0" VerticalAlignment="Top"  >
                <BulletDecorator.Bullet>
                    <Ellipse Height="8" Width="8" Fill="Blue"/>
                </BulletDecorator.Bullet>
                <TextBox TextWrapping="Wrap"  Background="Transparent" Text="100 : Manager" BorderThickness="0" />
            </BulletDecorator>
            <BulletDecorator Margin="5,40,0,0" VerticalAlignment="Top" >
                <BulletDecorator.Bullet>
                    <Ellipse Height="8" Width="8" Fill="Blue"/>
                </BulletDecorator.Bullet>
                <TextBox TextWrapping="Wrap" Background="Transparent" Text="200: Others" BorderThickness="0" />
            </BulletDecorator>
        </Grid>
    </Grid>
</DockPanel>
</Grid>

标签和项目符号装饰器放在网格行和列 (1,1) 的顶部,但不是用矩形制作的边框。我究竟做错了什么? Dockpanel 似乎正确地填充了网格中的整个 space(行=1,列=1)。

您需要将矩形的垂直对齐方式设置为顶部,以使其与 Bullet 装饰器相匹配