1
我想把一種用矩形做成的邊框和它內部的一個標籤和一些子彈裝飾器。我需要將它們放在網格的特定行和列中並放在頂部。在頂部的網格中定位dockpanel內容
<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似乎正確地填充了網格中的整個空間(row = 1,column = 1)。