You have two solutions:
- Place a transparent object on the left/top and animate it's Width/Height properties;
- Place the object you want to animate in a Canvas and animate the object Left/Top properties.
<UserControl.Resources>
<Storyboard x:FieldModifier="private" x:Name="SBUndeterminedAnimation">
<DoubleAnimation x:FieldModifier="private" x:Name="DAUndeterminedAnimation" AutoReverse="True" RepeatBehavior="Forever" Duration="0:0:2.000" From="0" Storyboard.TargetName="BProgress" Storyboard.TargetProperty="(Canvas.Left)" />
</Storyboard>
</UserControl.Resources>
<Grid>
<Canvas x:FieldModifier="private" x:Name="CTrack" Background="#19ff0000" Height="5" HorizontalAlignment="Stretch">
<Border x:FieldModifier="private" x:Name="BProgress" Background="#ffff0000" Height="5" Width="50" />
</Canvas>
</Grid>
This XAML is actually a custom ProgressBar that has both determined and undetermined behavior.The To property of the DAUndeterminedAnimation DoubleAnimation is set in code-behind.
Brilliant solution. Thanks!
ReplyDeleteTransform and Projection properties can be used in controls animations. So moving of control to the left can be done with projection's LocalOffsetX, instead of Margin -> Thickness -> Left.
ReplyDelete