Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Does anybody knows, if there is a way to use a property that is animated as source for a binding? As far as I found out, is that an animation doesn't "really" set the value on the property, and therefore doesn't fire the changed events, which is needed to trigger the binding.

tia Martin

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
675 views
Welcome To Ask or Share your Answers For Others

1 Answer

I don't know if what you are saying is exactly true. In the XAML below, the TextBlock will display the Width of the Rectangle. When you click on the Rectangle, the Width property is animated from 50 to 300. Along every increment, the TextBlock changes in value. Am I not understanding your question?

<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="*" />
    <RowDefinition Height="Auto" />
  </Grid.RowDefinitions>
  <TextBlock Text="{Binding ElementName=Rect,Path=Width}" Grid.Row="0" />
  <Rectangle Grid.Row="1"
             Name="Rect"
             Height="30"
             Width="50"
             Fill="Blue"
             HorizontalAlignment="Left">
    <Rectangle.Triggers>
      <EventTrigger RoutedEvent="Rectangle.MouseLeftButtonDown">
        <EventTrigger.Actions>
          <BeginStoryboard>
            <Storyboard>
              <DoubleAnimation Storyboard.TargetProperty="Width"
                From="50"
                To="300"
                Duration="0:0:10"/>
            </Storyboard>
          </BeginStoryboard>
        </EventTrigger.Actions>
      </EventTrigger>
    </Rectangle.Triggers>
  </Rectangle>
</Grid>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...