EventTrigger.Actions 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取事件发生时要应用的操作的集合。
public:
property System::Windows::TriggerActionCollection ^ Actions { System::Windows::TriggerActionCollection ^ get(); };
public System.Windows.TriggerActionCollection Actions { get; }
member this.Actions : System.Windows.TriggerActionCollection
Public ReadOnly Property Actions As TriggerActionCollection
属性值
默认值为空集合。
示例
此示例介绍如何使用样式中的事件触发器对 的 FrameworkElement和 MouseLeave 事件进行动画处理MouseEnter。 如上所述,向 对象添加TriggerAction子EventTrigger级会将其隐式添加到对象的 EventTrigger 。TriggerActionCollection 因此,在此示例中, <EventTrigger.Actions>
是隐式的。
<Style TargetType="Rectangle">
<Setter Property="Width" Value="50" />
<Setter Property="Height" Value="50" />
<Setter Property="Margin" Value="20" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Style.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation To="300" Duration="0:0:1.5"
AccelerationRatio="0.10" DecelerationRatio="0.25"
Storyboard.TargetProperty="(Canvas.Width)" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:1.5"
AccelerationRatio="0.10" DecelerationRatio="0.25"
Storyboard.TargetProperty="(Canvas.Width)" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Style.Triggers>
</Style>
注解
与 不同 Trigger, EventTrigger 没有终止状态的概念,因此一旦引发事件的条件不再成立,操作将不会撤消。
TriggerAction向 对象添加子EventTrigger级会将其隐式添加到 对象的 EventTrigger 。TriggerActionCollection
注意
此属性只能在 Extensible Application Markup Language (XAML) 中通过显示的集合语法设置,或者通过访问集合对象并使用其各种方法(如 Add)来设置。 用于访问集合对象本身的属性是只读的,集合本身是读写的。
XAML 属性元素用法
<object>
<object.Actions>
OneOrMoreTriggerActions
</object.Actions>
</object>
XAML 值
OneOrMoreTriggerActions
一个或多个 TriggerAction 对象。
适用于
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈