7

I have this grid with a border around it:

<Border Padding="0" BorderBrush="Orange" BorderThickness="2" CornerRadius="5">
    <Grid >                       
        <Label Grid.Row="0" Grid.Column="0" BorderBrush="Black"/>
        <Label Grid.Row="1" Grid.Column="0" BorderBrush="Black"/>
        <Label Grid.Row="0" Grid.Column="1" BorderBrush="Black"/>
        <Label Grid.Row="1" Grid.Column="1" BorderBrush="Black"/>
    </Grid>
</Border>

And the problem is, that the label borders overlap the orange border in the grid corners. It's probably because of the z-index. How to solve this problem?

enter image description here

Cobold
  • 2,563
  • 6
  • 34
  • 51

3 Answers3

5

See the following question: How to make the contents of a round-cornered border be also round-cornered?

It'll give you a result similar to this

enter image description here

Use it like

<local:ClippingBorder Padding="0" BorderBrush="Orange" BorderThickness="2" CornerRadius="5">
    <Grid >
        <!--...-->
    </Grid>
</local:ClippingBorder>
Community
  • 1
  • 1
Fredrik Hedblad
  • 83,499
  • 23
  • 264
  • 266
4

You could set the labels not to have a border on every side, like so

<Label Grid.Row="0" Grid.Column="0" BorderBrush="Black" BorderThickness="0,0,1,1" />
<Label Grid.Row="1" Grid.Column="0" BorderBrush="Black" BorderThickness="0,1,1,0"/>
<Label Grid.Row="0" Grid.Column="1" BorderBrush="Black" BorderThickness="1,0,0,1"/>
<Label Grid.Row="1" Grid.Column="1" BorderBrush="Black" BorderThickness="1,1,0,0"/>
Ray
  • 45,695
  • 27
  • 126
  • 169
0

Do you want the labels to have a complete outer border? If a gap between border and label is acceptable, you can set a margin on the grid

 <Grid Margin="2">
Dominik
  • 3,342
  • 1
  • 17
  • 24