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.
Unfortunately, activation email could not send to your email. Please try again.

Accordion Header Foreground Animation

Thread ID:

Created:

Updated:

Platform:

Replies:

125234 Aug 1,2016 06:24 PM Aug 11,2016 09:44 PM WPF 3
loading
Tags: SfAccordion
Harald Betzler
Asked On August 1, 2016 06:24 PM

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.


Vijayalakshmi Roopkumar [Syncfusion]
Replied On August 2, 2016 08:40 AM

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: 
 
<syncfusion:SfAccordion.HeaderTemplate>
<DataTemplate>
<Grid>
<Grid.Resources>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSourceMode=FindAncestor, AncestorType={x:Type syncfusion:SfAccordionItem}}}"Value="True">
<Setter Property="Foreground" Value="Red" />
</DataTrigger>
<DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSourceMode=FindAncestor, AncestorType={x:Type syncfusion:SfAccordionItem}}}"Value="False">
<Setter Property="Foreground" Value="Green" />
</DataTrigger>
</Style.Triggers>
</Style>
</Grid.Resources>
<TextBlock Text="{Binding}" Margin="10" FontSize="18"/>
</Grid>
</DataTemplate>
</syncfusion:SfAccordion.HeaderTemplate>
 

 
Regards, 
Vijayalakshmi V.R. 


Harald Betzler
Replied On August 4, 2016 07:53 AM

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.

Regards
Harald

Vijayalakshmi Roopkumar [Syncfusion]
Replied On August 11, 2016 09:44 PM

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: 

 XAML 
<VisualState x:Name="Collapsed"> 
<Storyboard> 
<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> 
<ColorAnimation Storyboard.TargetProperty="(ContentControl.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="header" To="Green"> 
</ColorAnimation> 
</Storyboard> 
</VisualState> 
<VisualState x:Name="Expanded"> 
<Storyboard> 
<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"/> 
</DoubleAnimationUsingKeyFrames> 
<ColorAnimation Storyboard.TargetProperty="Fill.Color" Storyboard.TargetName="arrow" To="{Binding Source={StaticResource ExpandedStroke},Path=Color}"> 
</ColorAnimation> 
<ColorAnimation Storyboard.TargetProperty="(ContentControl.Foreground).(SolidColorBrush.Color)" Duration="0:0:1" Storyboard.TargetName="header" To="Red"> 
</ColorAnimation> 
</Storyboard> 
</VisualState> 
 

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

Sample:SfAccordion_125234_Modified

Regards,
Vijayalakshmi V.R.
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;