Willy
Willy

Reputation: 10648

Positioning dockpanel content within a grid at the top

I am trying to put a kind of border made with rectangles and within it a label and some bullet decorators. I need to put them within a specific row and column of a grid and 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>

Label and bullet decorators are put at the top of the grid row and column (1,1) but border made with rectangles not. What am I doing wrong? Dockpanel seems correctly fill the entire space in grid (row=1,column=1).

Upvotes: 1

Views: 463

Answers (1)

Dave England
Dave England

Reputation: 46

You need to set the vertical alignment for the rectangles to be top to get them to match with the Bullet decorators

Upvotes: 2

Related Questions