Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Storyboard and ColumnDefinitions
1 replies. Latest Post by swildermuth on January 10, 2009.
(0)
ihilder
Member
4 points
8 Posts
01-09-2009 4:46 PM |
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
Star
8320 points
1,546 Posts
01-10-2009 5:46 AM |
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".