简体   繁体   English

带有进度指示器的CarouselPage?

[英]CarouselPage with progress indicator?

I have a registration page that has too many fields, that requires me to divide it into 4 pages, I thought that the best experience is to have a CarouselPage with four ContentPage s, that can be easily navigate through, and yet having one view with a corresponding view model. 我的注册页面包含太多字段,需要将其划分为4个页面,我认为最好的体验是拥有一个带有四个ContentPageCarouselPage ,可以轻松地浏览并使用一个视图相应的视图模型。 Before asking the main question, I want to make sure that I'm taking the right decision, and I didn't miss any other option that is dedicated for such case that I'm not aware of (I'm still in my first steps in Xamarin). 在问主要问题之前,我想确保我做出了正确的决定,并且我没有错过任何其他我不知道的专用选项(我仍然是第一个Xamarin中的步骤)。 if the CarouselPage is the way to go, then I want to have some indicator on the bottom of the screen, that shows the registration progress like a progress bar that increases by 25% on every next page, something that ties all the ContentPage s together 如果要使用CarouselPage ,那么我想在屏幕底部显示一些指示器,该指示器显示注册进度,例如进度条,该进度条在每个下一页上增加25%,并将所有ContentPage连接在一起

You can use the CarouselView which is the successor of CarouselPage. 您可以使用CarouselPage的后继者CarouselView。 There is a documentation how to implement CarouseView and here is nice blog post . 有一个文档如何实现CarouseView ,这是一个不错的博客文章

I can give you good idea how to start. 我可以给你一个好主意,如何开始。 CarouselViev is similar to ListView. CarouselViev与ListView相似。

<controls:CarouselViewControl 
    x:Name="MyCarouselView">
    <controls:CarouselView.ItemTemplate>
        <DataTemplate>
            <StackLayout>
                <Entry 
                    Placeholder="{Binding FirstEntryName}"
                    Text="{Binding FirstEntryText, Mode=TwoWay}"
                    IsVisible="{Binding FirstEntryVisible}" />
                <Entry 
                    Placeholder="{Binding SecondEntryName}"
                    Text="{Binding FirstEntryText, Mode=TwoWay}"
                    IsVisible="{Binding SecondEntryVisible}" />
            </StackLayout>
        </DataTemplate>
    </controls:CarouselView.ItemTemplate>
</controls:CarouselViewControl>

Then you can populate ItemSource with ObservableCollection DataFromEntries and MyViewData looks like this: 然后,您可以使用ObservableCollection DataFromEntries填充ItemSource,而MyViewData看起来像这样:

public class MyViewData
{
    public string FirstEntryName { get; set; }
    public string FirstEntryText { get; set; }
    public bool FirstEntryVisible { get; set; }
    public string SecondEntryName { get; set; }
    public string SecondEntryText { get; set; }
    public bool SecondEntryVisible { get; set; }
}

To enable Indicator you need to set property ShowIndicators to true. 要启用指标,您需要将属性ShowIndicators设置为true。

Try this one. 试试这个。 This article here is about carousel view with page indicator. 本文是关于带页面指示器的轮播视图。 https://xamarinhelp.com/carousel-view-page-indicators/ https://xamarinhelp.com/carousel-view-page-indicators/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM