请问如何在 <ControlTemplate.Triggers>里把background设置为渐变,而不是单一的颜色?如何把上面border的边框的颜色也一起修改?
- <Style x:Key="sureButton" TargetType="{x:Type Button}">
- <Setter Property="Margin" Value="0,10,4,0"></Setter>
- <Setter Property="Height" Value="32"></Setter>
- <Setter Property="Width" Value="88"></Setter>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type Button}">
- <Border BorderThickness="1" BorderBrush="#cfd3d6">
- <StackPanel Orientation="Horizontal" >
- <StackPanel.Background>
- <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
- <LinearGradientBrush.GradientStops>
- <GradientStop Color="#fbfbfb" Offset="0.0"/>
- <GradientStop Color="#f4f4f4" Offset="0.5"/>
- <GradientStop Color="#ebebeb" Offset="1.0"/>
- </LinearGradientBrush.GradientStops>
- </LinearGradientBrush>
- </StackPanel.Background>
- <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Padding="35,0,0,0" Foreground="#333">确 定</TextBlock>
- </StackPanel>
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter Property="Background" Value="red"></Setter>
- </Trigger>
- <Trigger Property="IsPressed" Value="True">
- <Setter Property="Background" Value="green"></Setter>
- </Trigger>
- <Trigger Property="IsEnabled" Value="False">
- <Setter Property="Background" Value="Yellow"></Setter>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
复制代码 |
|