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

[Bug] [Android] Adding new Cell to existing Table Section causes Java.Lang.IllegalStateException #2123

Closed
drasticactions opened this issue Aug 16, 2021 · 2 comments
Labels
partner/ui-tools .NET UI Tools partner Issue or Request from a partner team platform/android 🤖 t/bug Something isn't working

Comments

@drasticactions
Copy link
Contributor

Description

If you have an existing TableSection in a TableView, and invoke adding a new Cell to it (Ex, this.NewTableSection.Add(new TestCell());), the application will throw an Java.Lang.IllegalStateException.

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

This also happens with Xamarin.Forms, so most likely it's an underlying bug that was ported here.

Steps to Reproduce

Run this sample and click Add New Cell.
MauiTableView.zip

Expected Behavior

The new Cell gets added to the Section.

Actual Behavior

The application crashes.

@Redth Redth added partner Issue or Request from a partner team partner/ui-tools .NET UI Tools labels Aug 17, 2021
@Redth Redth added this to the 6.0.100-rc.2 milestone Aug 25, 2021
@zhongjohnson
Copy link

When I delete an item in the list that binding with the listview, it will also show me the same error "The specified child already has a parent. You must call removeView() on the child's parent first".

<ListView x:Name="instrumentsList" ItemsSource="{Binding Instruments}" HeightRequest="200" RowHeight="50"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <StackLayout Orientation="Horizontal"> <Label Text="{Binding Name}" /> <Label Text="{Binding Size}" /> <Button Text="Delete" Command="{Binding Source={RelativeSource AncestorType={x:Type local:SettingsViewModel}}, Path=DeleteInstrumentCommand}" CommandParameter="{Binding .}" /> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>

@jsuarezruiz jsuarezruiz added the t/bug Something isn't working label Oct 22, 2021
@Redth Redth removed this from the 6.0.101-preview.9 milestone Feb 9, 2022
@PureWeen
Copy link
Member

PureWeen commented Mar 4, 2022

This looks like it's fixed

I had to modify the code a little bit to set View on TestCell otherwise it crashed with 'ViewCell requires a View`

 this.NewTableSection.Add(new TestCell()
            {
                View = new Label() { Text = "rabbits" }
            });

But otherwise it seems to work now

@PureWeen PureWeen closed this as completed Mar 4, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Apr 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
partner/ui-tools .NET UI Tools partner Issue or Request from a partner team platform/android 🤖 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants