Trigger inheritance in WPF?

浪子不回头ぞ 提交于 2021-02-19 05:36:04

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!