silverlight-4.0 - 如何在 Silverlight 4 按钮上创建平面(即纯色、非渐变)颜色填充?

标签 silverlight-4.0

我刚刚开始使用 Silverlight,但我认为这很容易做到。我只是将一个按钮添加到一个新的 Silverlight 4 应用程序,但无论我将背景属性更改为(SolidColorBrush,任何颜色),只有部分按钮的渐变发生变化,我永远无法获得纯色、平坦的颜色填充。

这表明了我的意思: Butten still has gradient

为什么是红色渐变?我需要设置什么才能获得纯色填充?

最佳答案

您实际上需要为按钮创建一个新模板。

类似下面的内容:

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

关于silverlight-4.0 - 如何在 Silverlight 4 按钮上创建平面(即纯色、非渐变)颜色填充?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3681629/

相关文章:

c# - 无法引用工具包

xaml - 如何在 XAML 中的 CommandParam 中获得枚举值

firefox - à,É 等重音字符不适用于 google chrome + silverlight 4

c# - 在 C# Com 包装器中使用 native dll 并在 silverlight 中使用 dll

c# - 获取 ListBox 中的 ListBoxItem

xaml - 银光 4.0 : DataTemplate Error

c# - Visual Studio 2010 中的 json 支持

c# - 使用 C# 中的动态 com 互操作处理来自 Word 的事件

mvvm - 使用 MVVM 在 Silverlight 中将 CommandParameter 传递给 Command

c# - 在 Silverlight 中检查互联网连接