代码之家  ›  专栏  ›  技术社区  ›  Martin Moser

绑定到动画属性(WPF)

  •  2
  • Martin Moser  · 技术社区  · 17 年前

    短暂性脑缺血发作

    2 回复  |  直到 17 年前
        1
  •  4
  •   Szymon Rozga    17 年前

    <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>
    
        2
  •  2
  •   Nir    17 年前

    动画确实会更改值,它会调用传递给DependecProperty.Register的属性更改回调,并且会导致需要布局/渲染过程id。