Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Impossible to override a value in an animation located in a style?

Impossible to override a value in an animation located in a style?

Scheduled Pinned Locked Moved WPF
databasewpfquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mc_Topaz
    wrote on last edited by
    #1

    I have a style FooStyle with some properties and an animation. I have two other styles Bar1Style and Bar2Style which is based on the FooStyle 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 values FrameOneValue and FrameTwoValue.

    <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>
    
    L 1 Reply Last reply
    0
    • M Mc_Topaz

      I have a style FooStyle with some properties and an animation. I have two other styles Bar1Style and Bar2Style which is based on the FooStyle 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 values FrameOneValue and FrameTwoValue.

      <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>
      
      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups