如何从WPF上的ToggleButton事件开始动画

时间:2018-07-22 04:20:20

标签: wpf storyboard togglebutton

所以我有这个GridViewColumn

<GridViewColumn>
     <GridViewColumn.CellTemplate>
         <DataTemplate>
             <Grid>
                 <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="0" x:Name="cd"/>
                     <ColumnDefinition Width="50"/> 
                     <ColumnDefinition Width="50"/>
                     <ColumnDefinition Width="50"/>
                </Grid.ColumnDefinitions>
              </Grid>
          </DataTemplate>
      </GridViewColumn.CellTemplate>
  </GridViewColumn>

我有这个ToggleButton

<ToggleButton x:Name="toggleButtonEnableOptions"                           
               Checked="toggleButtonEnableOptions_Checked"                                                                     
               Unchecked="toggleButtonEnableOptions_Unchecked"/>

现在,当我的ToggleButtonChecked时,我希望名为cd的ColumnDefinition用以下动画进行扩展:

<Storyboard x:Key="animation">
    <DoubleAnimation Storyboard.TargetProperty="Height" 
                     From="0" To="30" 
                     DecelerationRatio=".9" 
                     Duration="0:0:0.3" />
</Storyboard>

有什么想法吗?

0 个答案:

没有答案