首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从旋转木马页面转到旋转木马视图

从旋转木马页面转到旋转木马视图
EN

Stack Overflow用户
提问于 2019-11-23 08:17:39
回答 2查看 1.7K关注 0票数 1

我在页面上看到了以下消息:https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/navigation/carousel-page

CarouselPage已被CarouselView取代,它提供了一个可滚动的布局,用户可以在其中滑动以移动一组项。有关CarouselView的更多信息,请参见Xamarin.Forms CarouselView。

在这方面,我决定开始使用CarouselView。但是,当我试图使用旋转木马来查找页面旋转木马时,得到了一个错误: ElementTemplateContent属性被设置了不止一次。

代码语言:javascript
复制
<CarouselView 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"
       xmlns:local="clr-namespace:test.Views"     
       x:Class="test.Corusel">
    <CarouselView.ItemTemplate>
        <DataTemplate>
            <local:Page1></local:Page1>
            <local:Page2></local:Page2>
        </DataTemplate>

    </CarouselView.ItemTemplate>
</CarouselView>

这是我想得到的结果。

代码语言:javascript
复制
<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"
       xmlns:local="clr-namespace:test.Views"     
       x:Class="test.Corusel">
    <CarouselPage.Children>
            <local:Page1></local:Page1>
            <local:Page2></local:Page2>
    </CarouselPage.Children>

我想使用旋转木马视图,因为我需要指示器。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-11-23 09:24:04

您的DataTemplate包含两个子元素。去掉一个,它就能工作了。

DataTemplate中只能有一个模板内容。

如果您想同时使用这两个页面,您可以在任何一个布局中添加两个页面,如StackLayoutContentViewContentPage等:

代码语言:javascript
复制
<CarouselView 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"
   xmlns:local="clr-namespace:test.Views"     
   x:Class="test.Corusel">
<CarouselView.ItemTemplate>
    <DataTemplate>
        <StackLayout>
              <local:Page1></local:Page1>
              <local:Page2></local:Page2>
        </StackLayout>
    </DataTemplate>

</CarouselView.ItemTemplate>

您可以将两个页面代码合并到一个页面中。

票数 2
EN

Stack Overflow用户

发布于 2019-11-23 11:05:57

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

https://stackoverflow.com/questions/59005796

复制
相关文章

相似问题

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