views:

21

answers:

2

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: Butten still has gradient

Why the red gradient? What do I need to set to get a solid color fill?

+1  A: 

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}" />
MojoFilter