我正在尝试向我的 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>
最佳答案
使用CarouselView
将 CarouselPage.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/