Articles in this section
Category / Section

How to enable/disable animated selection behavior in UWP Accordion control?

1 min read

UWP Accordion is a Control that organizes its contents in a form of Expand / Collapsible sections. It provides animation selection behavior when its item is expanded/collapsed and this can be achieved by customizing its ItemContainerStyle.

 

The following Code sample demonstrates the same.

 

Xaml

<!-- accordion Style-->
<!-- to Disable animation-->
<VisualState x:Name="Collapsed">                                      
     <Storyboard>
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:01" EnableDependentAnimation="True" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(ExpandableContentControl.Percentage)">
        <SplineDoubleKeyFrame KeySpline="0.2,0,0,1" KeyTime="00:00:0.0" Value="0" />
        </DoubleAnimationUsingKeyFrames>
      </Storyboard>
</VisualState>
<VisualState x:Name="Expanded">
     <Storyboard>
         <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:01" EnableDependentAnimation="True" Storyboard.TargetName="ExpandSite"
Storyboard.TargetProperty="(ExpandableContentControl.Percentage)">
          <SplineDoubleKeyFrame KeySpline="0.2,0,0,1" KeyTime="00:00:0.0" Value="1" />
          </DoubleAnimationUsingKeyFrames>
    </Storyboard>
</VisualState>
 
<!—accordion1 Style-->
<!-- Enable animation-->
 
<VisualState x:Name="Collapsed">
   <Storyboard>                                         
     <DoubleAnimationUsingKeyFrames BeginTime="00:00:01" Duration="00:00:10" EnableDependentAnimation="True" Storyboard.TargetName="ExpandSite" Storyboard.TargetProperty="(ExpandableContentControl.Percentage)">
       <SplineDoubleKeyFrame KeySpline="0.2,0,0,1" KeyTime="00:00:10.0" Value="0" />
     </DoubleAnimationUsingKeyFrames>
  </Storyboard>
 </VisualState>
<VisualState x:Name="Expanded">
  <Storyboard>
    <DoubleAnimationUsingKeyFrames BeginTime="00:00:01" Duration="00:00:10" EnableDependentAnimation="True" Storyboard.TargetName="ExpandSite” Storyboard.TargetProperty="(ExpandableContentControl.Percentage)">
       <SplineDoubleKeyFrame KeySpline="0.2,0,0,1" KeyTime="00:00:10.0" Value="1" />
      </DoubleAnimationUsingKeyFrames>
    </Storyboard>
 </VisualState>
</VisualStateGroup>
 
<!--to set the ItemContainerStyle for SfAccordion-->
 
<!--SfAccordion Disable Animation -->
<navigation:SfAccordion x:Name="accordion"  HorizontalAlignment="Center" VerticalAlignment="Center" Width="300" ItemContainerStyle="{StaticResource Style1}" Height="210">
<!--SfAccordion  Animation -->
<navigation:SfAccordion x:Name="accordion1"  HorizontalAlignment="Center" VerticalAlignment="Center" Width="300" ItemContainerStyle="{StaticResource Style2}" Height="210">        

 

Screenshot

 

SfAccordion Animation.

Figure 1: SfAccordion Animation.

 

Sample Links

 

C#: SfAccordionAnimation

VB: SfAccordionAnimation

 

 

 

Conclusion

I hope you enjoyed learning about how to enable/disable animated selection behavior in Accordion control.

You can refer to our UWP Accordion feature tour page to know about its other groundbreaking feature representations. You can also explore our UWP Accordion documentation to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied