WP7 网格中 Canvas 之间的转换
我在网格中有两个画布,我想要转换全场景“图像”,我想知道如何在这两个画布控件之间进行转换。
我以编程方式将第一个画布添加到网格中,然后将第二个画布添加到网格中,并删除第一个画布,我真正想做的是它们之间的转换。
关于如何以编程方式实现这一目标有什么建议吗?
谢谢。
编辑:我已经实现了这个方法,但是遇到了问题,任何人都可以告诉我我是否使用错误?
private void doTransitionIn(Canvas slide)
{
SlideTransition slideLeft = new SlideTransition();
slideLeft.Mode = SlideTransitionMode.SlideDownFadeIn;
ITransition transition = slideLeft.GetTransition(slide);
transition.Completed += delegate { transition.Stop(); }; transition.Begin();
}
private void doTransitionOut(Canvas slide)
{
SlideTransition slideLeft = new SlideTransition();
slideLeft.Mode = SlideTransitionMode.SlideDownFadeOut;
ITransition transition = slideLeft.GetTransition(slide);
transition.Completed += delegate { transition.Stop(); }; transition.Begin();
}
这是我如何使用它:
SceneGrid.Children.Add(nextCanvas);
doTransitionIn(nextCanvas);
doTransitionOut(currentCanvas);
SceneGrid.Children.Remove(currentCanvas);
问题是动画仅似乎是从屏幕下方的一部分开始,我只看到它滑动了最后 20 个左右的像素,它并没有一直滑动。
I have two canvas's in a Grid, full scene "images" that I want to transition, I wonder how I would go about transitioning between these two Canvas controls.
Programatically I add the first canvas to the grid, then I add the second canvas to the grid, and remove the first, what I really want to do is transition between them.
Any suggestions on how I might achieve this programatically?
Thanks.
Edit: I have implemented this method, but am having problems, anyone able to tell me if I'm using it wrong?
private void doTransitionIn(Canvas slide)
{
SlideTransition slideLeft = new SlideTransition();
slideLeft.Mode = SlideTransitionMode.SlideDownFadeIn;
ITransition transition = slideLeft.GetTransition(slide);
transition.Completed += delegate { transition.Stop(); }; transition.Begin();
}
private void doTransitionOut(Canvas slide)
{
SlideTransition slideLeft = new SlideTransition();
slideLeft.Mode = SlideTransitionMode.SlideDownFadeOut;
ITransition transition = slideLeft.GetTransition(slide);
transition.Completed += delegate { transition.Stop(); }; transition.Begin();
}
And here is how I use it:
SceneGrid.Children.Add(nextCanvas);
doTransitionIn(nextCanvas);
doTransitionOut(currentCanvas);
SceneGrid.Children.Remove(currentCanvas);
The problem with this is that the animation only seems to start from part way down the screen, as in, i only see it slide the last 20 or so pixels, it doesn't slide all the way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据“过渡”的含义,我会考虑创建一个故事板来为每个画布的隐藏/显示设置动画。
Depending on what you mean by "transition" I'd look at creating a StoryBoard to animate the hiding/showing of each canvas.
我建议使用
TransitioningContentControl
,它是 Silverlight Toolkit 的一部分。要使用此控件,请将您的第一个Canvas
设为该控件的Content
。要进行转换,只需将Content
更改为下一个Canvas
,然后TransitioningContentControl
即可完成剩下的工作!有许多博客文章提供了此控件的教程:
http://blogs.academicclub.org/uidev/2010/06/12/transitioning-content-in-silverlight/
I would recommend using the
TransitioningContentControl
which is part of the Silverlight Toolkit. To use this control, make your firstCanvas
theContent
of this control. To transition, simply change theContent
to your nextCanvas
and theTransitioningContentControl
does the rest!There are a number of blog posts that provide tutorials for this control:
http://blogs.academicclub.org/uidev/2010/06/12/transitioning-content-in-silverlight/