LSDev_KF

I'd like to create a rectangle that has barber pole animation. You remember those old red and white barber poles where the pole is continually turned and there's a cool spiral type affect I want to create a progress bar display that shows that kind of animation on a rectangle. Can anyone suggest the easiest way to achieve this affect



Re: Windows Presentation Foundation (WPF) Barber Pole Animation

Drew Marsh

Something like this

Code Snippet

<Rectangle x:Name="pole" Width="100" Height="20" Stroke="Black" StrokeThickness="1">
<Rectangle.Fill>
<DrawingBrush TileMode="Tile" Stretch="None" Viewbox="0,0,1,1" Viewport="0,0,25,25" ViewportUnits="Absolute">
<DrawingBrush.RelativeTransform>
<TranslateTransform X="0" Y="0" />
</DrawingBrush.RelativeTransform>
<DrawingBrush.Drawing>
<GeometryDrawing Brush="Red" Geometry="M10,0 25,0 15,25 0,25 Z" /> </DrawingBrush.Drawing>
</DrawingBrush>
</Rectangle.Fill>
<Rectangle.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="(Rectangle.Fill).(DrawingBrush.RelativeTransform).(TranslateTransform.X)" From="0" To=".25" RepeatBehavior="Forever" Duration="0:0:1" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Rectangle.Triggers>
</Rectangle>





Re: Windows Presentation Foundation (WPF) Barber Pole Animation

LSDev_KF

Fantastic - Thanks Drew!



Re: Windows Presentation Foundation (WPF) Barber Pole Animation

Crow007

This is a very good example, but it seems to have a bit of a jerk and it is not smooth... any idead to solve that issue

THANKS!!!!!

<Michael />





Re: Windows Presentation Foundation (WPF) Barber Pole Animation

Crow007

Hey Drew, any idea on how to get rid of that jerky motion in the animation of the pole

Let me know! Pleese! THNX

<Michael />





Re: Windows Presentation Foundation (WPF) Barber Pole Animation

Drew Marsh

I probably didn't get the timing/distance on the animation quite right as it was just a rough example, you should be able to clean it up based on the specifics of your geometry.





Re: Windows Presentation Foundation (WPF) Barber Pole Animation

Crow007

I guess the jerking happens if you remove the "width" value, but if the value is put back it runs smooth. Weird.

<Michael />





Re: Windows Presentation Foundation (WPF) Barber Pole Animation

Crow007

Yup, indeed it basically needed a few adjustments with the multiples of the number rules the width in this case the animation can be a .1 or a .05 if for instance you have a 5000 width.... now it work great!

Thanks!

<Michael />