问题
I have 2 triggers for a WPF TabItem control, both are identical except for this line:
<Setter Property="Opacity" Value="0.8" />
Is there any way I can make the trigger for IsMouseOver inherit from IsSelected and simply add the additional setter?Could you please provide an example if something like this is possible
Complete XAML:
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Panel.ZIndex" Value="100" />
<Setter TargetName="Border" Property="BorderThickness" Value="1" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Panel.ZIndex" Value="100" />
<Setter TargetName="Border" Property="BorderThickness" Value="1" />
<Setter Property="Opacity" Value="0.8" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
回答1:
Triggers don't inherit from each other. What you're trying to do isn't possible.
You can have styles inherit from each other, but not triggers.
来源:https://stackoverflow.com/questions/12726191/trigger-inheritance-in-wpf