We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Accordion Header Foreground Animation

Hi, I'm very new to syncfusion.

Wpf SfAccordions header item text is animated (changes foreground color from white to grey and vise versa).
Is there a possibility to set the colors (e.g. changes foreground color from green to red)?

I'm able to simple set the foreground color to red, but then I'll have no more animation.

3 Replies

VR Vijayalakshmi Roopkumar Syncfusion Team August 2, 2016 12:40 PM UTC

Hi Harald,

Thank you for contacting Syncfusion Support.

We have prepared a sample that tries to meet your requirement. To change the foreground for the header text on animation, we need to set the trigger to change the foreground when the header item get selected in the HeaderTemplate of SfAccordion. The same as has been depicted as below in the following code snippet as follows: 
 Code snippet: 
<Style TargetType="TextBlock">
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSourceMode=FindAncestor, AncestorType={x:Type syncfusion:SfAccordionItem}}}"Value="True">
<Setter Property="Foreground" Value="Red" />
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSourceMode=FindAncestor, AncestorType={x:Type syncfusion:SfAccordionItem}}}"Value="False">
<Setter Property="Foreground" Value="Green" />
<TextBlock Text="{Binding}" Margin="10" FontSize="18"/>

Vijayalakshmi V.R. 

HB Harald Betzler August 4, 2016 11:53 AM UTC

Hi Vijayalakshmi,

thank you for the quick response. It works! I'm happy. 

But in your snippet I had to replace "RelativeSourceMode=FindAncestor" with "RelativeSource FindAncestor".

Just one thing:
Now the colors change immediately. There is no more animation, which lets the colors change smoothly in the default configuration.


VR Vijayalakshmi Roopkumar Syncfusion Team August 12, 2016 01:44 AM UTC

Hi Harald,

Thank you for your update.

We have prepared a sample that tries to meet your requirement. In our sample, we have override the AccordionButtonStyle of SfAccordion, by setting the different Duration time and set the desired color using color animation in the Collapsed and Expanded Visual state. And set the AccordionButtonStyle to  achieve the animation for each of desired accordion item. Please find the code snippet for the same below: 

<VisualState x:Name="Collapsed"> 
<DoubleAnimation BeginTime="00:00:00" Duration="00:00:15" Storyboard.TargetName="icon" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" To="0"/> 
<ColorAnimation Storyboard.TargetProperty="Fill.Color" Storyboard.TargetName="arrow" To="{Binding Source={StaticResource CollapsedStroke},Path=Color}"> 
<ColorAnimation Storyboard.TargetProperty="(ContentControl.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="header" To="Green"> 
<VisualState x:Name="Expanded"> 
<DoubleAnimation BeginTime="00:00:00" Duration="00:00:15" Storyboard.TargetName="icon" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" To="90"/> 
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:5" Storyboard.TargetName="ExpandedBackground" Storyboard.TargetProperty="(UIElement.Opacity)"> 
<EasingDoubleKeyFrame KeyTime="00:00:01" Value="0.1"/> 
<EasingDoubleKeyFrame KeyTime="00:00:02" Value="0.4"/> 
<EasingDoubleKeyFrame KeyTime="00:00:03" Value="0.6"/> 
<EasingDoubleKeyFrame KeyTime="00:00:04" Value="0.8"/> 
<EasingDoubleKeyFrame KeyTime="00:00:015" Value="1"/> 
<ColorAnimation Storyboard.TargetProperty="Fill.Color" Storyboard.TargetName="arrow" To="{Binding Source={StaticResource ExpandedStroke},Path=Color}"> 
<ColorAnimation Storyboard.TargetProperty="(ContentControl.Foreground).(SolidColorBrush.Color)" Duration="0:0:1" Storyboard.TargetName="header" To="Red"> 

And we have also replaced the "RelativeSource Mode = FindAncestor" with "RelativeSource = FindAncestor" in this sample. Please download it from the following link:


Vijayalakshmi V.R.

Live Chat Icon For mobile
Up arrow icon