【发布时间】:2012-02-21 02:06:52
【问题描述】:
我想画一个简单的圆圈,并通过编码将其移动到 X、Y 轴上的定义位置。
例如;
WPF 窗口上会有 2 个按钮,0,0(x,y) 上会有一个圆圈。当我单击第一个按钮时,它将转到 X = 150 和 Y= 40。但形状必须顺利到达那里。我的意思是我不希望它在当前位置消失并出现在定义的位置。我想让它去那里。我该怎么做?你能解释一下步骤吗?如果可能的话,还有一些示例代码?
更新代码:
int X = 0;
int Y = 0;
public bool inside = true;
private void Button_Click_1(object sender, RoutedEventArgs e)
{
if (inside)
{
DoubleAnimation animatex = new DoubleAnimation();
animatex.To = X++;
// animatex.Duration = new Duration(TimeSpan.FromSeconds(1));
// animatex.RepeatBehavior = RepeatBehavior.Forever;
el.BeginAnimation(Canvas.LeftProperty, animatex);
DoubleAnimation animatey = new DoubleAnimation();
animatey.To = Y++;
// animatey.RepeatBehavior = RepeatBehavior.Forever;
el.BeginAnimation(Canvas.TopProperty, animatey);
}
}
【问题讨论】:
标签: c# wpf animation drawing geometry