如何从后面的代码到达我的ColumnDefinition Width属性

时间:2018-07-21 11:17:27

标签: wpf storyboard

所以我有这个Grid

<Grid.ColumnDefinitions>


<ColumnDefinition x:Name="IsSelectedColumnDefinition" Width="0"/>
                                                                                    <ColumnDefinition Width="60"/>
                                                                                    <ColumnDefinition Width="780"/>
                                                                                    <ColumnDefinition Width="60"/>
                                                                                </Grid.ColumnDefinitions>

GridDataTemplate内部:

<GridViewColumn>                                                          
    <GridViewColumn.CellTemplate>
        <DataTemplate>
             // MY GRID
        </DataTemplate>
    </GridViewColumn.CellTemplate>
</GridViewColumn>

因此,如您所见,我有这个x:Name="IsSelectedColumnDefinition",但仍然无法从后面的代码中获取。

我要做的就是从我的Storyboard点击Button开始Event

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

private void toggleButtonEnableOptions_Checked(object sender, RoutedEventArgs e)

按钮事件

{
    Storyboard storyboard = Resources["IsSelectedGrigWidth"] as Storyboard;
        if (storyboard != null)
            storyboard.Begin(IsSelectedColumnDefinition); // HERE i cannot reach this **IsSelectedColumnDefinition**
}

0 个答案:

没有答案