我的网格周围有一个边框:
<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>
问题是,标签边框与网格边角的橙色边框重叠。这可能是因为z-index。如何解决这个问题?
答案 0 :(得分:5)
请参阅以下问题:How to make the contents of a round-cornered border be also round-cornered?
它会给你一个与此类似的结果
像
一样使用它<local:ClippingBorder Padding="0" BorderBrush="Orange" BorderThickness="2" CornerRadius="5">
<Grid >
<!--...-->
</Grid>
</local:ClippingBorder>
答案 1 :(得分:2)
您可以设置标签不要在每一侧都有边框,如此
<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"/>
答案 2 :(得分:0)
您希望标签有完整的外边框吗?如果边框和标签之间的间隙可以接受,则可以在网格上设置边距
<Grid Margin="2">