<UserControl
x:Class="PointlessWaymarks.WpfCommon.WaitingSpinner.WaitingSpinnerControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="WaitSpinner"
mc:Ignorable="d">
<Grid DataContext="{Binding RelativeSource={RelativeSource Self}}">
<Path
Width="{Binding ElementName=WaitSpinner, Path=Diameter}"
Height="{Binding ElementName=WaitSpinner, Path=Diameter}"
RenderTransformOrigin=".5,.5"
Stroke="Transparent"
StrokeThickness=".1">
<Path.Data>
<CombinedGeometry GeometryCombineMode="Xor">
<CombinedGeometry.Geometry1>
<EllipseGeometry
Center="{Binding ElementName=WaitSpinner, Path=Center}"
RadiusX="{Binding ElementName=WaitSpinner, Path=Radius}"
RadiusY="{Binding ElementName=WaitSpinner, Path=Radius}" />
</CombinedGeometry.Geometry1>
<CombinedGeometry.Geometry2>
<EllipseGeometry
Center="{Binding ElementName=WaitSpinner, Path=Center}"
RadiusX="{Binding ElementName=WaitSpinner, Path=InnerRadius}"
RadiusY="{Binding ElementName=WaitSpinner, Path=InnerRadius}" />
</CombinedGeometry.Geometry2>
</CombinedGeometry>
</Path.Data>
<Path.Fill>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
<GradientStop Offset=".0" Color="{Binding ElementName=WaitSpinner, Path=Color1}" />
<GradientStop Offset=".25" Color="{Binding ElementName=WaitSpinner, Path=Color1}" />
<GradientStop Offset="1" Color="{Binding ElementName=WaitSpinner, Path=Color2}" />
</LinearGradientBrush>
</Path.Fill>
<Path.RenderTransform>
<RotateTransform />
<!-- This is necessary for the animation not to stop -->
</Path.RenderTransform>
<Path.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
RepeatBehavior="Forever"
Storyboard.TargetProperty="(Rectangle.RenderTransform).(RotateTransform.Angle)"
To="360"
Duration="0:0:1" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Path.Triggers>
</Path>
</Grid>
</UserControl>