我正在为 WPF 定义一个 Style TabControl
TabItem
。TabItem
我想在按下鼠标(左键)并且未选择时显示轻微的“按下”效果,TabItem
但我找不到Trigger
这个。
我试图定义一个MultiTrigger
withIsMouseLeftButtonDown
和IsPressed
属性,但没有一个被识别。
<Style TargetType="{x:Type TabItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabItem">
<Border Name="bd" BorderThickness="1,1,0,0">
<Grid>
<ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center"
ContentSource="Header"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseLeftButtonDown" Value="True" /> <!--NOT RECOGNIZED-->
<Condition Property="IsSelected" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="bd" Property="Background" >
<Setter.Value>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="Green" Offset="0"/>
<GradientStop Color="Yellow" Offset="1"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Trigger
当鼠标左键按下时,如何设置开始动作TabItem
?
编辑
我试过EventTrigger
了,但我没有看到下面的任何效果
<EventTrigger RoutedEvent="UIElement.PreviewMouseLeftButtonDown">
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="Green" Duration="0:0:3" />
</Storyboard>
<BeginStoryboard/>
<EventTrigger/>
可以通过这种方式以某种方式实现吗?