How to create a flat (i.e. Solid, non-gradient) color fill on a Silverlight 4 button?

I am just starting Silverlight, but I thought it would be easy to do. I just add a button to my new Silverlight 4 application, but no matter what I change the Background property (SolidColorBrush, any color), only part of the button gradient changes, I can never get a solid flat color fill.

This shows what I mean: Butten still has gradient

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

+3
source share
2 answers

You really need to create a new button template.

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}" />
+2
source

Source: https://habr.com/ru/post/1764086/


All Articles