Impossible to override a value in an animation located in a style?
-
I have a style
FooStyle
with some properties and an animation. I have two other stylesBar1Style
andBar2Style
which is based on theFooStyle
and sets some properties. I would like to alter the the values in the animation for the Bar-styles. In the animation I'm altering the buttons ScaleX and ScaleY values with the MouseIsOver trigger. In the code bellow you notice the valuesFrameOneValue
andFrameTwoValue
.<Style.Resources> <system:Double x:Key="FrameOneValue">1.0</system:Double> <system:Double x:Key="FrameTwoValue">1.05</system:Double> </Style.Resources> <Setter Property="FontWeight" Value="Bold" /> <Setter Property="RenderTransformOrigin" Value="0.5 0.5" /> <Setter Property="RenderTransform"> <Setter.Value> <TransformGroup> <ScaleTransform/> </TransformGroup> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Trigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)\[0\].(ScaleTransform.ScaleX)"> <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="{DynamicResource FrameOneValue}"/> <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="{DynamicResource FrameTwoValue}"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)\[0\].(ScaleTransform.ScaleY)"> <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="{DynamicResource FrameOneValue}"/> <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="{DynamicResource FrameTwoValue}"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </Trigger.EnterActions> <Trigger.ExitActions> <BeginStoryboard> <Storyboard> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(Transfor</x-turndown>
-
I have a style
FooStyle
with some properties and an animation. I have two other stylesBar1Style
andBar2Style
which is based on theFooStyle
and sets some properties. I would like to alter the the values in the animation for the Bar-styles. In the animation I'm altering the buttons ScaleX and ScaleY values with the MouseIsOver trigger. In the code bellow you notice the valuesFrameOneValue
andFrameTwoValue
.<Style.Resources> <system:Double x:Key="FrameOneValue">1.0</system:Double> <system:Double x:Key="FrameTwoValue">1.05</system:Double> </Style.Resources> <Setter Property="FontWeight" Value="Bold" /> <Setter Property="RenderTransformOrigin" Value="0.5 0.5" /> <Setter Property="RenderTransform"> <Setter.Value> <TransformGroup> <ScaleTransform/> </TransformGroup> </Setter.Value> </Setter> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Trigger.EnterActions> <BeginStoryboard> <Storyboard> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)\[0\].(ScaleTransform.ScaleX)"> <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="{DynamicResource FrameOneValue}"/> <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="{DynamicResource FrameTwoValue}"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)\[0\].(ScaleTransform.ScaleY)"> <EasingDoubleKeyFrame KeyTime="0:0:0.1" Value="{DynamicResource FrameOneValue}"/> <EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="{DynamicResource FrameTwoValue}"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </Trigger.EnterActions> <Trigger.ExitActions> <BeginStoryboard> <Storyboard> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(Transfor</x-turndown>
I'd create a new button "user control" that accepts 2 storyboard values and be done with it. Bind to public properties added to the UC. [Creating & using a UserControl - The complete WPF tutorial](https://wpf-tutorial.com/usercontrols-and-customcontrols/creating-using-a-usercontrol/)
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food