本文介绍了为每个角落设置不同画笔颜色的边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了一个静态资源定义在我的xaml中的特定项目的边框,但我找不到一个很好的方法来定义每一侧的唯一颜色!
I have created a static resource defining the border of a specific item in my xaml, but I can't find a good way to define a unique color for each side!
xaml:
<Border Style="{StaticResource SidePanelBorder}">
<!-- rest of the xaml -->
</Border>
StaticResource:
StaticResource:
<Style x:Key="SidePanelBorder">
<Setter Property="Control.BorderBrush" Value="#FF363636" />
<Setter Property="Control.BorderThickness" Value="1" />
</Style>
但是我想为边框的每一边定义一种颜色, 。
But I want to define one color for each side of the border, and eventually also a different Border thickness.
有什么好的技术吗?
推荐答案
看起来很黑,但你可以在边框内定义边框,只有一边有厚度。例如
Seems very hacky, but you could define borders within borders, and make only 1 side have a thickness. For example
<Border BorderThickness="0,0,0,10" BorderBrush="Green">
<Border BorderThickness="0,0,10,0" BorderBrush="Blue">
<Grid>
<Button>Hello</Button>
</Grid>
</Border>
</Border>
将在底部给出一个绿色边框,在右边给出一个蓝色边框。不是最漂亮的Xaml。
would give a green border on the bottom and a blue border to the right. Isn't the prettiest piece of Xaml though.
这篇关于为每个角落设置不同画笔颜色的边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!