【发布时间】:2021-11-10 13:22:39
【问题描述】:
我怎样才能使红色角落变圆? 我只想设置 MainBorder 的 CornerRadius 而不是第一个和最后一个 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>
【问题讨论】:
-
是的,类似的,但我尝试了那个解决方案,但我无法让它工作
-
尽量接近这个例子。您需要一个边框,在此边框内有一个网格,在此网格内您的不透明蒙版边框带有名称(以及半径)以及定义不透明蒙版的网格。不要试图缩短一些东西
-
将 ClipToBound="True" 添加到 MainBorder 属性
标签: c# wpf border rounded-corners