开发者

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

开发者 https://www.devze.com 2023-01-15 07:30 出处:网络
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

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:

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

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/

0

精彩评论

暂无评论...
验证码 换一张
取 消