dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.83k stars 1.67k forks source link

TableView - TableSection - Cells disappear when custom cells are updated on WinUI #22424

Open davidW83 opened 1 month ago

davidW83 commented 1 month ago

Description

The MAUI TableView control does some funny things. I've searched and found nothing regarding WinUI, only for Android without Shell.

I think it is basically the same issue from https://github.com/dotnet/maui/issues/16533 , thats why i stole the title. ;)

In my following tests this issue does not appear on Android! >edited

The cells dissappear and also mutliple cells that were added let the whole list collapse.

The issue is triggered by TableSection.Add / .Remove while using custom cells.

My question regarding this isuse are:

Steps to Reproduce

  1. My project uses the following versions.
    • I'm not using Shell
    • i tried MAUI 8.0.7 first without success.
<UseMaui>true</UseMaui>
<MauiVersion>8.0.21</MauiVersion>
<SingleProject>true</SingleProject>

<TargetFrameworks>net8.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.22621.0</TargetFrameworks>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
  1. A simple page with a TableView. As you can see it already contains some cells.

    <ContentPage.Content>
            <TableView  
                        Margin="3" 
                        Grid.Row="1" 
                        x:Name="tblMain" 
                        HasUnevenRows="True" 
                        HorizontalOptions="Fill" VerticalOptions="Fill" >
                <TableSection  Title="testSection" x:Name="tblSection1" >
                    <ViewCell>
                        <Label Text="Just a label "></Label>
                    </ViewCell>
                    <ViewCell>
                        <Grid ColumnDefinitions="*,Auto"> 
                            <Label Grid.Column="0" Text="Just another label" HorizontalOptions="Start"></Label>
                            <Switch Grid.Column="1" HorizontalOptions="End"></Switch>
                        </Grid>
                    </ViewCell>
                </TableSection>
            </TableView>
    </ContentPage.Content>
  2. Execute the following from anywhere, e.g. a Tolbaritem.Click()

    private void addCell()
    {
     var vc = new ViewCell();
     var lbl = new Label { Text = "tblSection1.count:" + tblSection1.Count }; ;
     vc.View = lbl;
     tblSection1.Add(vc);
    }
  3. See what happens.

    • the previously cells dissappear, but the new cell is being rendered
    • after adding mutliple cells, the list randomly collapses

Link to public reproduction project repository

No response

Version with bug

8.0.7 SR2

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

Windows, I was not able test on other platforms

Affected platform versions

Windos SDK 10.0.17763.0

Did you find any workaround?

The only workaround would not using a TableView, which would be a nightmare to refactor for Moving from Xamaroin to MAUI. :|

Relevant log output

No response

github-actions[bot] commented 1 month ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

davidW83 commented 1 month ago

tableview_error

Added an example gif

mattleibow commented 1 month ago

This was supposedly fixed in 8.0.7: https://github.com/dotnet/maui/commit/7af421e9a1745b3101e73781d040adec4789574a

But, it seems to still be here and this is slightly different maybe with adding items instead of changing items.

davidW83 commented 1 month ago

Ty, edited my comment regarding Android. The issue seems to appear on WinUI, but i tested it only on Android & WinUI.