![](/img/trans.png)
[英]How to use code-behind to create StackPanel -> Border -> Background
[英]How to use Border on StackPanel
因此,我再次尝试在WPF中开发应用程序。 我想在StackPanel
周围有一个漂亮的黑色边框,并带有圆形的corenrs。 为了做到这一点,我写了:
<Border x:Name="debugPanel" CornerRadius="10" BorderBrush="Black" BorderThickness="2" Grid.Row="5" Grid.Column="6" Grid.RowSpan="2">
<StackPanel Grid.RowSpan="3" Background="#C7C7C7">
<!--contents-->
</StackPanel>
</Border>
但是结果是丑陋的:(见下图:
请注意,添加边框甚至可能是错误的方法,我只是自己弄清楚了。 因此,如果您有任何建议和意见,我也很乐意听到。
在边框而不是StackPanel上设置背景:
<Border x:Name="debugPanel" Background="#C7C7C7" CornerRadius="10" BorderBrush="Black" BorderThickness="2" Grid.Row="5" Grid.Column="6" Grid.RowSpan="2">
<StackPanel Grid.RowSpan="3" Background="Transparent">
<!--contents-->
</StackPanel>
</Border>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.