Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Border overlapping problem

Tags:

wpf

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

like image 352
Cobold Avatar asked Aug 09 '11 13:08

Cobold


People also ask

How do you avoid double border in CSS?

Add a border-left and border-top to the parent. Add border-right and border-bottom to each of the children.


2 Answers

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>
like image 135
Fredrik Hedblad Avatar answered Oct 10 '22 03:10

Fredrik Hedblad


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"/>
like image 38
Ray Avatar answered Oct 10 '22 03:10

Ray