Accordion Header Foreground Animation
Hi, I'm very new to syncfusion.
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.
SIGN IN To post a reply.
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:
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>
|
Sample:SfAccordion_125234
Regards,
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.
Regards
Harald
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:
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.
Sample:SfAccordion_125234_Modified
Regards,
Vijayalakshmi V.R.
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
HB Harald Betzler
- Aug 1, 2016 10:24 PM UTC
- Aug 12, 2016 01:44 AM UTC