WP7 网格中 Canvas 之间的转换

发布于 2024-11-08 01:10:28 字数 1211 浏览 0 评论 0原文

我在网格中有两个画布,我想要转换全场景“图像”,我想知道如何在这两个画布控件之间进行转换。

我以编程方式将第一个画布添加到网格中,然后将第二个画布添加到网格中,并删​​除第一个画布,我真正想做的是它们之间的转换。

关于如何以编程方式实现这一目标有什么建议吗?

谢谢。

编辑:我已经实现了这个方法,但是遇到了问题,任何人都可以告诉我我是否使用错误?

     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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情徒 2024-11-15 01:10:28

根据“过渡”的含义,我会考虑创建一个故事板来为每个画布的隐藏/显示设置动画。

Depending on what you mean by "transition" I'd look at creating a StoryBoard to animate the hiding/showing of each canvas.

不喜欢何必死缠烂打 2024-11-15 01:10:28

我建议使用 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 first Canvas the Content of this control. To transition, simply change the Content to your next Canvas and the TransitioningContentControl 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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文