I am trying to get acquainted with WPF for an upcoming project. I have problems animating fields between states. Using Blend, I got the following XAML sample. If I call the "Big" state from the code, the rectangle suddenly expands after 1 second instead of "loosening" in the extension, which is the desired effect.
<Grid x:Name="LayoutRoot"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="VisualStateGroup"> <VisualStateGroup.Transitions> <VisualTransition GeneratedDuration="0:0:1"/> </VisualStateGroup.Transitions> <VisualState x:Name="Large"> <Storyboard> <ThicknessAnimationUsingKeyFrames Storyboard.TargetProperty="(FrameworkElement.Margin)" Storyboard.TargetName="rectangle"> <EasingThicknessKeyFrame KeyTime="0" Value="64,135,47,191"/> </ThicknessAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Rectangle x:Name="rectangle" Fill="#FFF4F4F5" Margin="428,135,47,191" Stroke="Black"/> </Grid>
Thanks in advance!
source share