Skip to main content

Microsoft Silverlight

Answered Question Storyboard and ColumnDefinitionsRSS Feed

(0)

ihilder
ihilder

Member

Member

4 points

8 Posts

Storyboard and ColumnDefinitions

 I have a small XML feed display panel in an application I'm developing which has some images surrounding it.  I need to have the ability to change the width of the Column that the text being displayed exists in.  The easiest way to do this would be to change the ColumnDefinition.Width.  I'm not sure what I should be referencing as the Storyboard.TargetProperty.  Here's a glimpse at the code I'm working with:

The aninmation:

<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="FeedSelectorWidth" Storyboard.TargetProperty="(FrameworkElement.Width)">
                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="260"/>
                <SplineDoubleKeyFrame KeyTime="00:00:04.500000" Value="260"/>
                <SplineDoubleKeyFrame KeyTime="00:00:04.75" Value="240"/>
                <SplineDoubleKeyFrame KeyTime="00:00:05" Value="260"/>
  </DoubleAnimationUsingKeyFrames>

 The XAML:

 <Grid x:Name="FeedPanel" Background="Transparent" RenderTransformOrigin="0.5,0.5" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition x:Name="FeedSelectorWidth" Width="260"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>

Any help that could be provided would be great.  Thanks in advance.

 

swildermuth
swildermuth

Star

Star

8320 points

1,546 Posts

Answered Question

Re: Storyboard and ColumnDefinitions

Two problems that cause this not to work is that the DoubleAnimation requires a numeric value (and the Width property is a GridWidth object, not a number). Also, the Width property isn't a DependencyProperty so it can't be animated. 

The workaround is to create a rectangle (Opacity=0) in the gridrow and animate its width and set the ColumnDefinition's WIdth to "Auto".

(If this has answered your question, "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 3 Workshop
Miami, FL: Oct 12-14th
Portlant, OR: Dec 2-4th
Atlanta, GA: Dec 7-9th
http://silverlight-tour.com
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities