views:

709

answers:

4

Hi,

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

+4  A: 

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>
siz
+2  A: 

Animation does actually really change the value, it does call the property changed callback you pass to DependecyProperty.Register and it does cause a layout/render pass id needed.

Nir
A: 

thx for help I made a really bad mistake...

Martin Moser