2017-07-27 37 views
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)。

回答

2

您需要将矩形的垂直对齐设置为顶部,以使它们与子弹装饰器匹配