首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >旋转木马页面导航

旋转木马页面导航
EN

Stack Overflow用户
提问于 2020-03-25 18:32:23
回答 1查看 271关注 0票数 0

我只是想问一下旋转木马页面的流向。所以我正在试着想出一些办法来解决我的问题。我有一个有2个按钮的主页,其中一个带我到旋转木马1,向右滑动我得到旋转木马2,另一个向右滑动旋转木马2到旋转木马1。然而,我被要求改变流程,所以如果我去旋转木马2我向左滑动得到旋转木马1。

代码语言:javascript
复制
I have tried switch case but for some reason the first page doesnt load properly


     //    System.Threading.Thread.Sleep(500);
                //    //model.Busy = false;
                //    Device.BeginInvokeOnMainThread(async () =>
                //    {
                //        switch (_pages)
                //        {
                //            case Pages.Reading:
                //                await Navigation.PushAsync(new CarouselLearning(false), false);
                //                break;
                //            case Pages.Listening:
                //                await Navigation.PushAsync(new CarouselLearning(true), false);
                //                break;

                //        }
                //        Navigation.RemovePage(this);
                //    });
                //});

and then i tried just simple navigation which of course dosent work
 private async void OnListeningButtonClicked(object sender, EventArgs e) 
        {
            await Navigation.PushAsync(new CarouselLearning(Listening));
        }

你有这方面的经验吗?

EN

回答 1

Stack Overflow用户

发布于 2020-03-26 15:10:59

Carousel Page中,您可以通过设置CurrentPage来选择转到旋转木马1或旋转木马2,例如:

代码语言:javascript
复制
public MainPageCS(bool isReading) {

    var greenContentPage = new ContentPage
    {
        Padding = padding,
        Content = new StackLayout {
        ...
    }
    };
    var blueContentPage = new ContentPage
    {
        Padding = padding,
        Content = new StackLayout {
        ...
    }
    };

    Children.Add(blueContentPage );
    Children.Add(greenContentPage);

    if (isReading)
    {
        this.CurrentPage = greenContentPage;
    }
    else
    {
        this.CurrentPage = blueContentPage ;
    }
}

如果您转到旋转木马1,则向右滑动转到旋转木马2,如果您转到旋转木马2,则向左滑动转到旋转木马1。

顺便说一句,你也可以使用CarouselView来达到你想要的效果。

导航到CarouselLearning页面时,将CurrentItem设置为转盘1或转盘2。

或者使用CarouselView的FlowDirection

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60846986

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档