VisualTransition.GeneratedEasingFunction Property

Definition

Gets or sets a custom mathematical formula that is used to transition between states.

public:
 property System::Windows::Media::Animation::IEasingFunction ^ GeneratedEasingFunction { System::Windows::Media::Animation::IEasingFunction ^ get(); void set(System::Windows::Media::Animation::IEasingFunction ^ value); };
public System.Windows.Media.Animation.IEasingFunction GeneratedEasingFunction { get; set; }
member this.GeneratedEasingFunction : System.Windows.Media.Animation.IEasingFunction with get, set
Public Property GeneratedEasingFunction As IEasingFunction

Property Value

A custom mathematical formula that is used to transition between states.

Examples

The following example creates a VisualTransition that causes a Rectangle to move vertically when the user presses the mouse button over the Canvas. The example sets the GeneratedEasingFunction property to a BounceEase object to cause the Rectangle to appear to bounce when it reaches its destination. The VisualTransition that is used when the user releases the button has another BounceEase object to cause the Rectangle to bounce before it returns to its original position.

<Canvas Name="canvasRoot" Background="Tan" Width="100" Height="250"
        MouseDown="Canvas_MouseEvent" MouseUp="Canvas_MouseEvent">

  <VisualStateManager.VisualStateGroups>
    <VisualStateGroup Name="CanvasStates">
      <VisualState Name="CanvasButtonUp" />
      <VisualState Name="CanvasButtonDown">
        <Storyboard>
          <!--The VisualTransition is responsible for animating the
              Rectangle falling. This DoubleAnitmation specifies where
              the Rectangle is when the animation completes.-->
          <DoubleAnimation To="200" 
                           Storyboard.TargetName="myRectangle" 
                           Storyboard.TargetProperty="(Canvas.Top)"/>
        </Storyboard>
      </VisualState>
      <VisualStateGroup.Transitions>
        <VisualTransition To="CanvasButtonUp" GeneratedDuration="00:00:01">
          <VisualTransition.GeneratedEasingFunction>
            <BounceEase Bounces="4" EasingMode="EaseIn" Bounciness="2"/>
          </VisualTransition.GeneratedEasingFunction>
        </VisualTransition>
        <VisualTransition To="CanvasButtonDown" GeneratedDuration="00:00:01">
          <VisualTransition.GeneratedEasingFunction>
            <BounceEase Bounces="3" EasingMode="EaseOut" Bounciness="2"/>
          </VisualTransition.GeneratedEasingFunction>
        </VisualTransition>

      </VisualStateGroup.Transitions>
    </VisualStateGroup>
  </VisualStateManager.VisualStateGroups>

  <Rectangle Name="myRectangle"  
             Canvas.Top="30" Canvas.Left="30"
             Fill="Blue" Width="30" Height="30"/>
</Canvas>

The following example shows the event handler for the MouseDown and MouseUp events. The example calls the GoToElementState method to change the VisualState of the canvas.

bool isMouseDown;

private void Canvas_MouseEvent(object sender, MouseEventArgs e)
{
    isMouseDown = !isMouseDown;

    if (isMouseDown)
    {
        VisualStateManager.GoToElementState(canvasRoot, "CanvasButtonDown", true);
    }
    else
    {
        VisualStateManager.GoToElementState(canvasRoot, "CanvasButtonUp", true);
    }
}
Private isMouseDown As Boolean

Private Sub Canvas_MouseEvent(ByVal sender As Object, ByVal e As MouseEventArgs)

    isMouseDown = Not isMouseDown

    If isMouseDown Then
        VisualStateManager.GoToElementState(canvasRoot, "CanvasButtonDown", True)
    Else

        VisualStateManager.GoToElementState(canvasRoot, "CanvasButtonUp", True)
    End If
End Sub

Remarks

You can set the GeneratedEasingFunction property to specify the way a transition occurs. For example, you can specify an easing function to accelerate or decelerate the transition. For more information, see Easing Functions.

Applies to