我用自旋控件制作了一个文本框。
我只想在鼠标悬停在这些按钮上而不是在“文本框”的鼠标悬停时更改“ +”,“-”按钮的背景颜色。
这是带有微调框的文本框的样式
<Style x:Key="PlushMinus" TargetType="{x:Type RepeatButton}">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#18689a"/>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="SpinButton" TargetType="Slider">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Slider">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="20"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="0"/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBox Grid.RowSpan="3" Background="#057aa5" BorderBrush="#FFABADB3" Text="{Binding Value,Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" BorderThickness="1,1,0,1" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Padding="2.8,1.55,0,0" Foreground="White"/>
<RepeatButton Style="{StaticResource PlushMinus}" Name="BtnPlush" Grid.Column="1" Grid.Row="0" Command="Slider.IncreaseLarge" BorderThickness="0,0,0,.5" BorderBrush="Transparent" Background="#2da5da">
<fa:ImageAwesome Margin="0,.5,0,0" Icon="Plus" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" Height="6" Width="6"/>
</RepeatButton>
<Rectangle Grid.Column="1" Grid.Row="1" Fill="Red" Height="0"/>
<RepeatButton Style="{StaticResource PlushMinus}" Name="BtnMinus" Grid.Column="1" Grid.Row="2" Command="Slider.DecreaseLarge" BorderThickness="0,.5,0,0" BorderBrush="Transparent" Background="#2da5da">
<fa:ImageAwesome Margin="0,0,0,0" Icon="Minus" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White" Height="6" Width="6"/>
</RepeatButton>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="RepeatButton.IsMouseOver" Value="True">
<Setter TargetName="BtnPlush" Property="Background" Value="#18689a"/>
</Trigger>
<Trigger Property="RepeatButton.IsMouseOver" Value="True">
<Setter TargetName="BtnMinus" Property="Background" Value="#18689a"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
谢谢。
任何帮助都是有意义的。