TabItem的内容应该能够在TabItem上触发事件,这很奇怪。我试图在悬停和悬停时为我的TabItem设置动画,这样可以正常运行,但事件也是在儿童悬停和儿童悬停时触发,因为你可以成像不是很好:
<!-- TABCONTROL -->
<Style TargetType="{x:Type TabItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid Name="grdTab" Margin="0,0,5,0" Height="20" MinWidth="80">
...
</Grid>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="MouseLeave">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource GlowOut}"></BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
<EventTrigger RoutedEvent="MouseEnter">
<EventTrigger.Actions>
<BeginStoryboard Storyboard="{StaticResource GlowIn}"></BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
如何阻止悬停事件触发儿童的悬停事件?
答案 0 :(得分:0)
将父级的悬停事件e.Handled
设置为true
。