Animating the RadExpander control.
To enable or disable the animation you can use the IsAnimationEnabled attached property of the AnimationManager class. By default the Animation is enabled for the RadExpander. Below are code-snippets for XAML and C#:
CopyXAML
<StackPanel Orientation="Horizontal">
<telerik:RadExpander telerik:AnimationManager.IsAnimationEnabled="False" />
<telerik:RadExpander telerik:AnimationManager.IsAnimationEnabled="True" />
</StackPanel>
CopyC#
using Telerik.Windows.Controls.Animation;
private void SetAnimation()
{
if (this.radExpander != null)
{
AnimationManager.SetIsAnimationEnabled(this.radExpander, false);
AnimationManager.SetIsAnimationEnabled(this.radExpander, true);
}
}
CopyVB.NET
Imports Telerik.Windows.Controls.Animation
Private Sub SetAnimation()
If Me.radExpander IsNot Nothing Then
AnimationManager.SetIsAnimationEnabled(Me.radExpander, False)
AnimationManager.SetIsAnimationEnabled(Me.radExpander, True)
End If
End Sub
You can further edit the default animations of the RadExpander using the AnimationSelector attached property of the AnimationManager class. By default the following animations are defined for the RadExpander control:
CopyXAML
<Style x:Key="RadExpanderStyle" TargetType="telerik:RadExpander">
...
<Setter Property="telerik:AnimationManager.AnimationSelector">
<Setter.Value>
<telerik:AnimationSelector>
<telerik:ExpanderExpandCollapseAnimation AnimationName="Expand"
Direction="In"
TargetElementName="Content" />
<telerik:ExpanderExpandCollapseAnimation AnimationName="Collapse"
Direction="Out"
TargetElementName="Content" />
</telerik:AnimationSelector>
</Setter.Value>
</Setter>
</Style>
You can control the speed of the animations through the SpeedRatio property:
CopyXAML
<Style x:Key="RadExpanderStyle" TargetType="telerik:RadExpander">
...
<Setter Property="telerik:AnimationManager.AnimationSelector">
<Setter.Value>
<telerik:AnimationSelector>
<telerik:ExpanderExpandCollapseAnimation AnimationName="Expand"
Direction="In"
SpeedRatio="0.2"
TargetElementName="Content" />
<telerik:ExpanderExpandCollapseAnimation AnimationName="Collapse"
Direction="Out"
SpeedRatio="0.2"
TargetElementName="Content" />
</telerik:AnimationSelector>
</Setter.Value>
</Setter>
</Style>