在另一个LinearGradientBrush中使用LinearGradientBrush? [英] Use a LinearGradientBrush in another LinearGradientBrush?
问题描述
我想在另一个LinearGradientBrush的定义中使用一个LinearGradientBrush。但我不知道天气这甚至可以工作,如果它的工作,我需要知道如何。
I'm trying to use one LinearGradientBrush in the Definition of another LinearGradientBrush. But I've no idea weather this would even work, and if it works, I need to know how.
例如:
<LinearGradientBrush x:Key="ComboBoxFocusBackgroundBrush" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFFDEEB3" Offset="0"/>
<GradientStop Color="#FFFBF2CD" Offset="1"/>
<GradientStop Color="#FFFCE48A" Offset="0.5"/>
<GradientStop Color="#FFFBE388" Offset="0.75"/>
</LinearGradientBrush>
<LinearGradientBrush x:Key="FilterPopupTitleBrush" EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#B45988" Offset="0.75"/>
//Code here to use ComboBoxFocusBackgroundBrush
<GradientStop Color="#990088" Offset="0.75"/>
</LinearGradientBrush>
感谢您预期答案
编辑:
为了使事情更清楚在示例中我想使用FilterPopupTitleBrush中的ComboBoxFocusBackgroundBrush作为一个模板。因为我有两个画笔没有副本相同的颜色渐变的< GradientStop ...>标签
To get things a bit more clear in the example I want to use "ComboBoxFocusBackgroundBrush" in the "FilterPopupTitleBrush" as a "template".So that I've the same color gradient in both brushes without a copy of the "<GradientStop...>"-tags
推荐答案
您可以共享多个画笔之间的渐变停留列表,像这样: -
You can share the list of gradient stops between multiple brushes, like this:-
<GradientStopCollection x:Key="MyGradient">
<GradientStop Color="#FFFDEEB3" Offset="0"/>
<GradientStop Color="#FFFBF2CD" Offset="1"/>
<GradientStop Color="#FFFCE48A" Offset="0.5"/>
<GradientStop Color="#FFFBE388" Offset="0.75"/>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ComboBoxFocusBackgroundBrush" EndPoint="0.5,1" StartPoint="0.5,0"
GradientStops="StaticResource MyGradient}" />
<LinearGradientBrush x:Key="FilterPopupTitleBrush" EndPoint="0.5,1" StartPoint="0.5,0"
GradientStops="{StaticResource MyGradient}" />
现在您可以改变 EndPoint
code> StartPoint 和其他属性创建相同基本渐变的不同变体。
Now you can vary the EndPoint
, StartPoint
and other properties create different variants of the same basic gradient.
你甚至可以提供相同的集合到 RadialGradientBrush
。
You can even supply the same set to RadialGradientBrush
.
这篇关于在另一个LinearGradientBrush中使用LinearGradientBrush?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!