xamarin - 如何在CarouselPage中使用IndicatorView?

标签 xamarin xamarin.forms xamarin.android xamarin.ios

我正在尝试向我的 CarouselPage 添加指示器 View 样式点;但是,我找到的文档仅显示了如何将新的 IndicatorView 与 CarouselView 一起使用。

是否可以将其与 CarouselPage 一起使用?如果没有,是否有类似于用于 CarouselPage 的 IndictorView 的东西?这是我的代码:

<?xml version="1.0" encoding="utf-8"?>
<CarouselPage
    xmlns="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:d="http://xamarin.com/schemas/2014/forms/design"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    x:Class="Page.MainPage">
    <ContentPage>
        <StackLayout Padding="0,20,0,0">
                <Image Source="LOGO.png"
                       HorizontalOptions="Center"
                       VerticalOptions="Center"
                       HeightRequest="195"
                       WidthRequest="205"
                       />
                <AbsoluteLayout HorizontalOptions="Center" VerticalOptions="Center">
                      <Image Source="bg.png"
                             AbsoluteLayout.LayoutBounds="0.35, 0.6, -1, 1" 
                             AbsoluteLayout.LayoutFlags="PositionProportional"          
                             HeightRequest="330"
                             WidthRequest="200"/>
                      <Image Source="Device.png"
                             AbsoluteLayout.LayoutBounds="0.45, 0.4, -1, -1" 
                             AbsoluteLayout.LayoutFlags="PositionProportional"  
                             HeightRequest="252"
                             WidthRequest="290"/>
                </AbsoluteLayout>     
                <StackLayout>
                    <Label Text="Welcome"
                       HorizontalTextAlignment="Center"
                       VerticalTextAlignment="Center"
                       TextColor="White"
                       Padding="0,15"
                       Font="Bold,20"/>

                    <Label Text="This is page 1"
                       HorizontalTextAlignment="Center"
                       VerticalTextAlignment="Center"
                       FontSize="18"
                       Padding="25,0"
                       TextColor="White"/>
                </StackLayout>
        </StackLayout>
    </ContentPage>
    <ContentPage BackgroundColor="#3e454d">
        <StackLayout BackgroundColor="#3e454d">     
                <AbsoluteLayout>
                      <Image Source="Map.png"
                             AbsoluteLayout.LayoutBounds="0.4, 0.7, -1, -1" 
                             AbsoluteLayout.LayoutFlags="PositionProportional"          
                             HeightRequest="330"
                             WidthRequest="205"/>
                      <Image Source="Device.png"
                             AbsoluteLayout.LayoutBounds="0.45, 0.7, -1, -1" 
                             AbsoluteLayout.LayoutFlags="PositionProportional"  
                             HeightRequest="282"
                             WidthRequest="340"/>
                </AbsoluteLayout>     
                <StackLayout Padding="10,10">
                    <Label Text="Join US"
                       TextColor="White"
                       Padding="0,0,0,15"
                       Font="Bold,22"/>

                    <Label Text="This is Page 2"
                       HorizontalTextAlignment="Center"
                       FontSize="18"
                       TextColor="White"/>
                </StackLayout>
        </StackLayout>
    </ContentPage>
</CarouselPage>

最佳答案

使用CarouselViewCarouselPage.Content 嵌入到 CarouselView.ItemLayout 中,而不是 CarouselPage ,如 documentation 中所述。

请注意, IndicatorView 是不同的 View ,它没有嵌入到 CarouselPage 中,即使在 CarouselView 中,您也必须提供对 CarouselView 的绑定(bind)引用才能使其工作。

另请注意,IndicatorView 仍在 Preview 中模式,您需要设置实验标志才能使其工作

 Forms.SetFlags("IndicatorView_Experimental");

它也显示Carouselview is in preview too(It was not, weird!)

所以你可能还需要为此设置实验标志

Forms.SetFlags("CarouselView_Experimental");

关于xamarin - 如何在CarouselPage中使用IndicatorView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60939773/

相关文章:

c# - SQLiteNet 索引和 Lambda 表达式

xamarin - AppLink Xamarin 表单未建立索引

c# - Xamarin.Forms 中的 Application.Current Null 异常

c# - 如何在 xamarin 的 ListView 中使用 OnItemLongClick

c# - 如何确定我的程序集是否可以被 Mono、MonoTouch、MonoDroid 使用?

xamarin - 如何在xamarin(Android)应用程序中删除导航后退按钮和页面标题之间的额外空间或减少额外空间?

android - 如何在 Android 应用程序上以编程方式打开 GPS

c# - 将 xamarin 表单与 IServiceProvider 一起使用

carousel - Xamarin.Forms 轮播中的页面指示器,可能吗?

xamarin - 如何更改 Xamarin 中的复选框/单选按钮颜色?