admin管理员组

文章数量:1277886

I want to use a CarouselView to show multiple pages in a MAUI app. But it does not work properly only for windows platform. For Android it works fine.

I defined the carousel:

<CarouselView ItemsSource="{Binding Pages}" IsSwipeEnabled="True" Loop="False">
    <CarouselView.ItemTemplate>
        <DataTemplate>
            <ContentView Content="{Binding}"/>
        </DataTemplate>
    </CarouselView.ItemTemplate>
</CarouselView>

The code behind is:

public MainPage()
{
    InitializeComponent();

    Pages = new ObservableCollection<ContentView>();
    Pages.Add(new Page1());
    Pages.Add(new Page2());
    Pages.Add(new Page3());

    BindingContext = this;
}

public ObservableCollection<ContentView> Pages { get; set; }

The pages are all defined as ContentView because Carousel only accepts ContentViews for content. A sample of page ist:

<ContentView xmlns=";
             xmlns:x=";
             x:Class="MauiTest.Page1">
    <Grid HorizontalOptions="Fill" VerticalOptions="Fill" Background="Blue">
        <Label 
            Text="Page 1"
            FontSize="48"
            VerticalOptions="Center" 
            HorizontalOptions="Center" />
    </Grid>
</ContentView>

If I start it on windows, the first page is not shown in the carousel. The is a white band on the left side of the window and the second page is shown partially. When I swipe to the other pages, the pages are shown in the right manner. This only occurs on the windows platform. On Android it works fine.

What is the problem on the windows platform ?

Is that a bug ?

本文标签: cMAUI Carousel omit first page for windows platformStack Overflow