我里面有一个 DockPanel 和一个按钮。我想在停靠面板中按事件(例如,鼠标悬停)为按钮设置动画(例如,淡入/淡出)。
编辑
好吧,我发现解决方案仅适用于非模板/非样式案例(见下文)。如何把它带到可重用的方式?
<DockPanel>
<Button>
Name="aaa"
</Button>
<DockPanel.Triggers>
<EventTrigger RoutedEvent="DockPanel.MouseEnter">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Duration="0:0:0.100"
To="1"
Storyboard.TargetName="aaa"
Storyboard.TargetProperty="Opacity"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="DockPanel.MouseLeave">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Duration="0:0:0.100"
To="0"
Storyboard.TargetName="aaa"
Storyboard.TargetProperty="Opacity"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</DockPanel.Triggers>
</DockPanel>