gpt4 book ai didi

c# - MultiDataTrigger 不起作用?

转载 作者:太空宇宙 更新时间:2023-11-03 19:26:59 25 4
gpt4 key购买 nike

我想为我的 TabControl 使用一个 MultiDataTrigger。悬停在选项卡时,应更改颜色。但如果选择了 Tab,则不会。我尝试了 MultiDataTrigger。但这似乎不起作用。这是我的风格:

<Style TargetType="{x:Type TabItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid>
<Border Name="Border" BorderBrush="Black" BorderThickness="0.5,0.5,0.5,0" CornerRadius="4,4,0,0">
<ContentPresenter x:Name="ContentSite" VerticalAlignment="Center" HorizontalAlignment="Center" ContentSource="Header" Margin="12,2,12,2"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Border" Property="Background">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#fefeff" Offset="0" />
<GradientStop Color="#e7edf6" Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Border" Property="Background">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#c5d0df" Offset="0" />
<GradientStop Color="#aab4c2" Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=IsMouseOver}" Value="True" />
<Condition Binding="{Binding Path=IsSelected}" Value="False" />
</MultiDataTrigger.Conditions>
<Setter TargetName="Border" Property="Background">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#dde6f2" Offset="0" />
<GradientStop Color="#c6d0de" Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</MultiDataTrigger>

</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>

有什么问题吗?

最佳答案

将触发器更改为:

<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="false"/>
<Condition Property="IsMouseOver" Value="true"/>
</MultiTrigger.Conditions>

根据 AngelWPF's回答一个 DataTrigger 将尝试绑定(bind)到当前的 DataContext,它将在其中找不到与属性匹配的内容。

关于c# - MultiDataTrigger 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7886048/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com