37
我有在我所定义如何我的每一个窗口在我的应用程序的外观风格一个MainResources.xaml文件:在XAML风格中,如何将纯色背景更改为渐变?
<Style x:Key="MainBorderStyle" TargetType="{x:Type Border}">
<Setter Property="Background" Value="WhiteSmoke" />
<Setter Property="BorderBrush" Value="LightGray" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="5" />
<Setter Property="SnapsToDevicePixels" Value="True" />
</Style>
相反“的WhiteSmoke”我想我的背景是这样的梯度:
<LinearGradientBrush>
<GradientStop Color="#ccc" Offset="0"/>
<GradientStop Color="#bbb" Offset="1"/>
</LinearGradientBrush>
但接下来的尝试会导致VS2008告诉我“风格制定者不支持子元素”:
<Style x:Key="MainBorderStyle" TargetType="{x:Type Border}">
<Setter Property="Background">
<LinearGradientBrush>
<GradientStop Color="#ccc" Offset="0"/>
<GradientStop Color="#bbb" Offset="1"/>
</LinearGradientBrush>
</Setter>
<Setter Property="BorderBrush" Value="LightGray" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="CornerRadius" Value="5" />
<Setter Property="SnapsToDevicePixels" Value="True" />
</Style>
什么是用c还是以正确的方式将渐变颜色作为此样式的背景?
完美,谢谢! – 2009-02-06 13:41:13