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. WCF and WF
  4. Animate a button when mouse is over

Animate a button when mouse is over

Scheduled Pinned Locked Moved WCF and WF
question
4 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
    mikla521
    wrote on last edited by
    #1

    What am I doing wrong this time? I want a button to change the scale when mouse is over. I'm really missing something, cause this doesn't work. But what is wrong?

    <Button Name="MyScaleButton" >
    <Button.Triggers>
    <EventTrigger RoutedEvent="Button.MouseEnter">
    <EventTrigger.Actions>
    <BeginStoryboard>
    <Storyboard>
    <DoubleAnimation Storyboard.TargetProperty="(Button.RenderTransform).(ScaleTransform.ScaleX)"
    From="1" To="2" Duration="0:0:1">
    </DoubleAnimation>
    </Storyboard>
    </BeginStoryboard>
    </EventTrigger.Actions>
    </EventTrigger>
    </Button.Triggers>
    My Button
    </Button>

    Nothing at all happens here. Must be wrong in the TargetProperty?

    M 1 Reply Last reply
    0
    • M mikla521

      What am I doing wrong this time? I want a button to change the scale when mouse is over. I'm really missing something, cause this doesn't work. But what is wrong?

      <Button Name="MyScaleButton" >
      <Button.Triggers>
      <EventTrigger RoutedEvent="Button.MouseEnter">
      <EventTrigger.Actions>
      <BeginStoryboard>
      <Storyboard>
      <DoubleAnimation Storyboard.TargetProperty="(Button.RenderTransform).(ScaleTransform.ScaleX)"
      From="1" To="2" Duration="0:0:1">
      </DoubleAnimation>
      </Storyboard>
      </BeginStoryboard>
      </EventTrigger.Actions>
      </EventTrigger>
      </Button.Triggers>
      My Button
      </Button>

      Nothing at all happens here. Must be wrong in the TargetProperty?

      M Offline
      M Offline
      mikla521
      wrote on last edited by
      #2

      Ok, from the beginning I started with a style. Seems like I missed to add..

      <Setter Property="LayoutTransform">
      <Setter.Value>
      <ScaleTransform/>
      </Setter.Value>
      </Setter>

      Why is that necessary? Anyway, it works fine now.

      M 2 Replies Last reply
      0
      • M mikla521

        Ok, from the beginning I started with a style. Seems like I missed to add..

        <Setter Property="LayoutTransform">
        <Setter.Value>
        <ScaleTransform/>
        </Setter.Value>
        </Setter>

        Why is that necessary? Anyway, it works fine now.

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        I can see why the first one didn't work, since there was no ScaleTransform set on the button's RenderTransform property. I don't understand how this fixed it, however :)

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        1 Reply Last reply
        0
        • M mikla521

          Ok, from the beginning I started with a style. Seems like I missed to add..

          <Setter Property="LayoutTransform">
          <Setter.Value>
          <ScaleTransform/>
          </Setter.Value>
          </Setter>

          Why is that necessary? Anyway, it works fine now.

          M Offline
          M Offline
          Mark Salsbery
          wrote on last edited by
          #4

          That doesn't work for me. This does:

          <Grid Width="100" Height="50" >
          <Button Name="MyScaleButton" HorizontalAlignment="Center" VerticalAlignment="Center">
          <Button.RenderTransform> <ScaleTransform /> </Button.RenderTransform>
          <Button.Triggers>
          <EventTrigger RoutedEvent="Button.MouseEnter">
          <EventTrigger.Actions>
          <BeginStoryboard>
          <Storyboard>
          <DoubleAnimation Storyboard.TargetProperty="(Button.RenderTransform).(ScaleTransform.ScaleX)" From="1" To="2" Duration="0:0:1">
          </DoubleAnimation>
          </Storyboard>
          </BeginStoryboard>
          </EventTrigger.Actions>
          </EventTrigger>
          </Button.Triggers>
          My Button
          </Button>
          </Grid>

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          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