Skip to content

Latest commit

 

History

History
59 lines (45 loc) · 2.79 KB

frameworkelement_triggers.md

File metadata and controls

59 lines (45 loc) · 2.79 KB
-api-id -api-type
P:Windows.UI.Xaml.FrameworkElement.Triggers
winrt property

Windows.UI.Xaml.FrameworkElement.Triggers

-description

Gets the collection of triggers for animations that are defined for a FrameworkElement. Not commonly used. See Remarks.

-xaml-syntax

<frameworkElement>
  <frameworkElement.Triggers>
    oneorMoreTriggers
  </frameworkElement.Triggers>
</frameworkElement>

-xaml-values

oneorMoreTriggers
oneorMoreTriggersOne or more object elements of type EventTrigger.
## -property-value The collection of triggers for animations that are defined for this object.

-remarks

Triggers, EventTrigger, Actions and BeginStoryboard are not commonly used. These API mainly exist for compatibility in XAML originally used for Microsoft Silverlight. For most scenarios where event triggers were used previously, you should use built-in animations, visual states, or start animations by writing a Loaded handler that looks up an animation in page-level resources and then calls Begin on the animation's main Storyboard. For more info, see Quickstart: Control templates or Storyboarded animations.

-examples

This XAML example shows the basic structure for using FrameworkElement.Triggers with its default FrameworkElement.Loaded trigger behavior to run a storyboarded animation. This XAML shows the EventTrigger and BeginStoryboard container elements in proper relationship with each using their XAML content property syntax and unnecessary property element tags omitted.

<Canvas Width="200" Height="200" x:Name="animatedcanvas" Background="Red">
    <Canvas.Triggers>
        <EventTrigger>
            <BeginStoryboard>
                <Storyboard x:Name="ColorStoryboard">
                   <!-- Animate the background of the canvas to green over 4 seconds. -->
                    <ColorAnimation Storyboard.TargetName="animatedcanvas"
                      Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)"
                      To="Green" Duration="0:0:4" />
                </Storyboard>
            </BeginStoryboard>
        </EventTrigger>
    </Canvas.Triggers>
</Canvas>

-see-also

Storyboard