Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CarouselView displaying views through DataTemplate throws exception when loop is enabled #9744

Closed
KPHIBYE opened this issue Aug 29, 2022 · 1 comment
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView high It doesn't work at all, crashes or has a big impact. platform/android 🤖 platform/windows 🪟 t/bug Something isn't working

Comments

@KPHIBYE
Copy link

KPHIBYE commented Aug 29, 2022

Description

When setting the ItemsSource of a CarouselView to a collection of views and specifying a DataTemplate with a ContentView or ContentPresenter to display it, a Java.Lang.IllegalStateException is thrown on Android that says

The specified child already has a parent. You must call removeView() on the child's parent first

On Windows, if everything is left untouched, the first View is not displayed and a very long horizontal scrollbar is displayed on the bottom. If Loop is disabled, the first view is still not displayed but the horizontal scrollbar is not present. If Loop is disabled and the converter workaround described below is used, it seems to behave normally (scroll not tested). If Loop is enabled and the converter workaround is used, and the horizontal scrollbar is used, it scrolls uncontrolled and very fast.

I did not test this on other platforms besides Android and Windows.

Steps to Reproduce

Reproduction Repository

OR

Just add this to a View

<CarouselView Loop="True">
    <CarouselView.ItemsSource>
        <x:Array Type="{x:Type Label}">
            <Label Text="Item 1" />
            <Label Text="Item 2" />
        </x:Array>
    </CarouselView.ItemsSource>
    <CarouselView.ItemTemplate>
        <DataTemplate>
            <ContentView Content="{Binding}" />
        </DataTemplate>
    </CarouselView.ItemTemplate>
</CarouselView>

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows

Affected platform versions

Android 5 and up, Windows 10.0.17763.0 and up

Did you find any workaround?

Yes, setting Loop to false, or writing an IValueConverter that removes the view from the parent.

Relevant log output

No response

@KPHIBYE KPHIBYE added the t/bug Something isn't working label Aug 29, 2022
@jsuarezruiz jsuarezruiz added area-controls-collectionview CollectionView, CarouselView, IndicatorView t/bug Something isn't working high It doesn't work at all, crashes or has a big impact. and removed t/bug Something isn't working labels Aug 29, 2022
@PureWeen
Copy link
Member

Duplicate #7884

@ghost ghost locked as resolved and limited conversation to collaborators Sep 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView high It doesn't work at all, crashes or has a big impact. platform/android 🤖 platform/windows 🪟 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants