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. How to binding to the actual width and height of the control in doubleanimation?

How to binding to the actual width and height of the control in doubleanimation?

Scheduled Pinned Locked Moved WPF
tutorialcsswpfwcfquestion
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.
  • E Offline
    E Offline
    Eric Vonjacson
    wrote on last edited by
    #1

    Hi, I add a expander to a window and the double animation when is expanded. However, the to property of the doubleanimation is hardcoded, in my example, the "to" property is 200 and 400. I want to ask that how could it binding to the actual width or height of the expander control? Is this possible?

    <Expander Grid.Column="3" Grid.RowSpan="2" Header="expander1" Margin="3,12,-83,18" Name="expander1" BorderBrush="Red" BorderThickness="2" Width="200" Height="400">
    <StackPanel>
    <Button Width="100">This is the button one</Button>
    <Button Width="100">This is the button two</Button>
    </StackPanel>

      <Expander.Triggers>
        <EventTrigger RoutedEvent="Expander.Expanded">
          <BeginStoryboard>
            <Storyboard>
              <DoubleAnimation Storyboard.TargetName="expander1" Storyboard.TargetProperty="Width"
                               From="0" To="200" Duration="0:0:0.25" />
              <DoubleAnimation Storyboard.TargetName="expander1" Storyboard.TargetProperty="Height"
                               From="0" To="400" Duration="0:0:0.25" />
            </Storyboard>
          </BeginStoryboard>
        </EventTrigger>
      </Expander.Triggers>
    </Expander>
    

    thanks.

    P 1 Reply Last reply
    0
    • E Eric Vonjacson

      Hi, I add a expander to a window and the double animation when is expanded. However, the to property of the doubleanimation is hardcoded, in my example, the "to" property is 200 and 400. I want to ask that how could it binding to the actual width or height of the expander control? Is this possible?

      <Expander Grid.Column="3" Grid.RowSpan="2" Header="expander1" Margin="3,12,-83,18" Name="expander1" BorderBrush="Red" BorderThickness="2" Width="200" Height="400">
      <StackPanel>
      <Button Width="100">This is the button one</Button>
      <Button Width="100">This is the button two</Button>
      </StackPanel>

        <Expander.Triggers>
          <EventTrigger RoutedEvent="Expander.Expanded">
            <BeginStoryboard>
              <Storyboard>
                <DoubleAnimation Storyboard.TargetName="expander1" Storyboard.TargetProperty="Width"
                                 From="0" To="200" Duration="0:0:0.25" />
                <DoubleAnimation Storyboard.TargetName="expander1" Storyboard.TargetProperty="Height"
                                 From="0" To="400" Duration="0:0:0.25" />
              </Storyboard>
            </BeginStoryboard>
          </EventTrigger>
        </Expander.Triggers>
      </Expander>
      

      thanks.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      You could always replace this with To="{Binding ElementName=expander1, Path=ActualWidth}"

      "WPF has many lovers. It's a veritable porn star!" - Josh Smith

      My blog | My articles | MoXAML PowerToys

      E 1 Reply Last reply
      0
      • P Pete OHanlon

        You could always replace this with To="{Binding ElementName=expander1, Path=ActualWidth}"

        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

        My blog | My articles | MoXAML PowerToys

        E Offline
        E Offline
        Eric Vonjacson
        wrote on last edited by
        #3

        I tried that. It works. Thanks a lot. Eric

        P 1 Reply Last reply
        0
        • E Eric Vonjacson

          I tried that. It works. Thanks a lot. Eric

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          You're welcome. I'm glad to help - and a 5 for the thanks. :-D

          "WPF has many lovers. It's a veritable porn star!" - Josh Smith

          My blog | My articles | MoXAML PowerToys

          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