WPF 一组图片循环移动

x624722359 2012-06-28 10:53:21
要实现的是 一个视图里面有几张图片排列在一起,然后他们一起从屏幕左边往右边移动,当此组图片显示完毕,然后接着又从头开始移动。如此反复,希望牛人指点。最好有例子。
...全文
280 4 打赏 收藏 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
x624722359 2012-07-11
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

你可以移动Canvas 当从左边移动到右边的时候 你让他在返回左边继续做运动,这个需要用到动画
Image img = new Image();

img = _obj as Image;

if (img.Opacity > 1)
{
img.……
[/Quote]没搞定。。没人来。就你的还行。分给你了
x624722359 2012-07-11
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

我有个不是图片的循环滚动示例,把滚动的文本数据,替换成图片就可以实现你说的效果。不过中间你要设置好图片的路径即可。
资源位置:http://download.csdn.net/detail/david_xgl/4340219
[/Quote]你的那个不是WPF。。我晕
yulie_1234 2012-06-28
  • 打赏
  • 举报
回复
你可以移动Canvas 当从左边移动到右边的时候 你让他在返回左边继续做运动,这个需要用到动画
Image img = new Image();

img = _obj as Image;

if (img.Opacity > 1)
{
img.Opacity = img.Opacity / 100;
}

double actime;
double delaytime;
if (ca.Time == "0")
{

}
if (!ca.IsTimer)
{
actime = 0.1;
}
else
{
if (double.Parse(ca.Time) == 0)
{
actime = 0.1;
}
else
{
actime = double.Parse(ca.Time);
}
}
Storyboard sb = new Storyboard();
// ImageDelBinding(img);
if (ca.IsWidth)
{
DoubleAnimation widthA = new DoubleAnimation(img.Width, double.Parse(ca.Width), new Duration(TimeSpan.FromSeconds(actime)));
Storyboard.SetTargetProperty(widthA, new PropertyPath(Image.WidthProperty));
sb.Children.Add(widthA);
}
if (ca.IsHeight)
{
DoubleAnimation heightA = new DoubleAnimation(img.Height, double.Parse(ca.Height), new Duration(TimeSpan.FromSeconds(actime)));
Storyboard.SetTargetProperty(heightA, new PropertyPath(Image.HeightProperty));
sb.Children.Add(heightA);
}
if (ca.IsX)
{
DoubleAnimation leftA = new DoubleAnimation(double.Parse(img.GetValue(Canvas.LeftProperty).ToString()), double.Parse(ca.X), new Duration(TimeSpan.FromSeconds(actime)));
Storyboard.SetTargetProperty(leftA, new PropertyPath(Canvas.LeftProperty));
sb.Children.Add(leftA);
}
if (ca.IsY)
{
DoubleAnimation topA = new DoubleAnimation(double.Parse(img.GetValue(Canvas.TopProperty).ToString()), double.Parse(ca.Y), new Duration(TimeSpan.FromSeconds(actime)));
Storyboard.SetTargetProperty(topA, new PropertyPath(Canvas.TopProperty));
sb.Children.Add(topA);
}
if (ca.IsAlpha)
{
double alpha_d;
if (double.Parse(ca.Alpha) > 1)
{
alpha_d = double.Parse(ca.Alpha) / 100;
}
else {
alpha_d = double.Parse(ca.Alpha) ;
}
DoubleAnimation oA = new DoubleAnimation(img.Opacity, alpha_d, new Duration(TimeSpan.FromSeconds(actime)));
Storyboard.SetTargetProperty(oA, new PropertyPath(Image.OpacityProperty));
sb.Children.Add(oA);
}

if (!ca.IsDelay)
{
delaytime = 0;
}
else
{
delaytime = double.Parse(ca.Delay);
}
// sb.FillBehavior = FillBehavior.Stop;
sb.Completed += new EventHandler(sb_Completed);
sb.BeginTime = TimeSpan.FromSeconds(delaytime);
sb.Begin(img);
大概的动画 可以这样来做 你看一下自己组织组织
微恒软件 2012-06-28
  • 打赏
  • 举报
回复
我有个不是图片的循环滚动示例,把滚动的文本数据,替换成图片就可以实现你说的效果。不过中间你要设置好图片的路径即可。
资源位置:http://download.csdn.net/detail/david_xgl/4340219

8,757

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧