I'm just beginning Silverlight, yet I thought this would be easy to do. I simply add a button to a new Silverlight 4 application but no matter what I change the Background property to (SolidColorBrush, any color), only part of button's gradient changes,开发者_开发问答 I can never get a solid, flat color fill.
This shows what I mean:
Why the red gradient? What do I need to set to get a solid color fill?
You would actually need to create a new Template for the button.
Something like the following:
<Canvas.Resources>
<Style x:Key="flatButton" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}">
<ContentPresenter />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Canvas.Resources>
...
<Button Style="{StaticResource flatButton}" />
Here, apparently, is the answer:
http://deepumi.wordpress.com/2010/02/21/silverlight-change-button-background-color/
精彩评论