我怎样才能使红色的拐角处变成圆角?我只想设置CornerRadius的MainBorder,而不是为第一个也是最后一个InnerBorder设置
如果我设置了textBlocks的背景(而不是InnerBorders),则行为是相同的
<Border Name="MainBorder" Background="Transparent" Width="250" Height="250" BorderBrush="Black" BorderThickness="3" CornerRadius="20" Margin="500,500,0,0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Border Name="brdInner1" Grid.Row="0" BorderBrush="Black" BorderThickness="0,0,0,0" Background="Transparent">
<TextBlock />
</Border>
<Border Name="brdInner2" Grid.Row="1" BorderBrush="Black" BorderThickness="0,3,0,0" Background="Red">
<TextBlock />
</Border>
<Border Name="brdInner3" Grid.Row="2" BorderBrush="Black" BorderThickness="0,3,0,0" Background="Red">
<TextBlock />
</Border>
</Grid>
</Border>
发布于 2021-09-15 16:31:31
使用ClippingBorder
类here,只需更改主边框的类型:
<local:ClippingBorder x:Name="MainBorder" ...>
发布于 2021-09-15 17:48:12
之所以会发生这种情况,是因为虽然主边框具有CornerRadius属性集,但子边界仍然设置为正方形,但我已将CornerRadius添加到您的上一个边界控件中。
<Border Name="MainBorder" Background="Transparent" Width="250" Height="250" BorderBrush="Black" BorderThickness="3" CornerRadius="20" Margin="500,500,0,0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Border Name="brdInner1" Grid.Row="0" BorderBrush="Black" BorderThickness="0,0,0,0" Background="Transparent">
<TextBlock />
</Border>
<Border Name="brdInner2" Grid.Row="1" BorderBrush="Black" BorderThickness="0,3,0,0" Background="Red">
<TextBlock />
</Border>
<Border Name="brdInner3" Grid.Row="2" BorderBrush="Black" BorderThickness="0,3,0,0" Background="Red" CornerRadius="0,0,20,20">
<TextBlock />
</Border>
</Grid>
</Border>
https://stackoverflow.com/questions/69193363
复制相似问题