我无法弄清楚如何使背景og组合框在顶部几乎透明和底部几乎是纯白色之间淡入淡出。
我想以这样的风格设置背景:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!--Groups and borders-->
<Style x:Key="MainGroupBox" TargetType="{x:Type GroupBox}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="SnapsToDevicePixels" Value="True" />
</Style>
我希望你能帮助我。
PS:我正在使用带有WPF 4的C#
答案 0 :(得分:2)
嗨,FireFly我认为您不了解XAML的强大功能,它来自xml,因此您可以在重新标记的标签下添加任何已识别的元素。像
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush>
<GradientStop Offset="0.5" Color="Red" />
<GradientStop Offset="0.3" Color="Black" />
<GradientStop Offset="0.9" Color="Yellow" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
或
<Setter Property="Background">
<Setter.Value>
<RadialGradientBrush>
<GradientStop Offset="0.5" Color="Red" />
<GradientStop Offset="0.3" Color="Black" />
<GradientStop Offset="0.9" Color="Yellow" />
</RadialGradientBrush>
</Setter.Value>
</Setter>
答案 1 :(得分:0)
你的风格必须是:
<Style x:Key="MainGroupBox" TargetType="{x:Type GroupBox}">
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush>
<GradientStop Color="Transparent" Offset="0"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
... other properties
</Style>
(我的颜色可能很受欢迎(我正在从记忆中打字)