How to highlight GridLength animation from "Auto" to "*"?

I need to animate this property using a Storyboard . Is it better to write your own animation?

+4
source share
1 answer

No, it is quite possible to use standard XAML:

 <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" x:Name="col0"/> <ColumnDefinition/> </Grid.ColumnDefinitions> <Grid.Resources> <Storyboard x:Key="sbCol0ToAuto"> <ObjectAnimationUsingKeyFrames BeginTime="0" Duration="0" Storyboard.TargetName="col0" Storyboard.TargetProperty="Width"> <DiscreteObjectKeyFrame KeyTime="0"> <DiscreteObjectKeyFrame.Value> <GridLength>*</GridLength> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </Grid.Resources> ... </Grid> 

And it’s even easier to return to auto

 <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static GridLength.Auto}"> 
+7
source

Source: https://habr.com/ru/post/1300902/


All Articles