How to animate wpf ellipse size to center point?
My solution:
private void drawEllipseAnimation()
{
if (pointEl.Width == 16)
{
DoubleAnimation myDoubleAnimation = new DoubleAnimation();
myDoubleAnimation.From = 16;
myDoubleAnimation.To = 22;
myDoubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.5));
pointEl.BeginAnimation(Ellipse.WidthProperty, myDoubleAnimation);
pointEl.BeginAnimation(Ellipse.HeightProperty, myDoubleAnimation);
if (pointEl.Width == 22)
{
DoubleAnimation myDoubleAnimation2 = new DoubleAnimation();
myDoubleAnimation2.From = 22;
myDoubleAnimation2.To = 16;
myDoubleAnimation2.Duration = new Duration(TimeSpan.FromSeconds(0.5));
pointEl.BeginAnimation(Ellipse.WidthProperty, myDoubleAnimation2);
pointEl.BeginAnimation(Ellipse.HeightProperty, myDoubleAnimation2);
}
}
WPF Code:
<Ellipse Fill="#FFCA2437" Width="16" Height="16" Margin="10" Name="pointEl">
<Ellipse.Effect>
<BlurEffect Radius="3" KernelType="Gaussian"/>
</Ellipse.Effect>
</Ellipse>
But this animate in top and left point. My idea change ellipse size to ellipse center point.
eg.: drawEllipseAnimation(); put DispatcherTimer event.