question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ListView ViewCell content disappears when the application enters the foreground

See original GitHub issue

Description

A simple page consists only a ListView, which has a ViewCell as DataTemplate.

When the app on iOS (whether device or simulator) goes to the background and then back to the foreground, the content of the CellViews disappears. Only empty cells remain.

Steps to Reproduce

  1. Create a New .NET MAUI App from the template
  2. Replace the content of MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="ListTest.MainPage">

    <ContentPage.ToolbarItems>

    </ContentPage.ToolbarItems>

    <ListView>

        <ListView.ItemsSource>
            <x:Array Type="{x:Type x:String}">
                <x:String>One</x:String>
                <x:String>Two</x:String>
                <x:String>Three</x:String>
            </x:Array>
        </ListView.ItemsSource>

        <ListView.ItemTemplate>
            <DataTemplate x:DataType="x:String">
                <ViewCell>
                    <Grid
                        ColumnDefinitions="80,*">
                        <Button Text="{Binding .}"/>
                    </Grid>
                </ViewCell>
            </DataTemplate>
        </ListView.ItemTemplate>

    </ListView>

</ContentPage>
  1. Run the app on iOS Simulator 16.0. The app shows a list with three lines of buttons.
  2. Send the app to the background. Do not close the app!
  3. Pull the app back to the foreground

What should happen:

The app looks like before.

What happens instead:

The three lines are still visible, but the buttons disappear.

Link to public reproduction project repository

https://github.com/ultra133/ListTest.git

Version with bug

7.0 (current)

Last version that worked well

This worked with Xamarin! So it’s a big issue when migrating to .NET MAUI.

Affected platforms

iOS

Affected platform versions

iOS 16

Did you find any workaround?

No

Relevant log output

No response

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Reactions:9
  • Comments:26 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
nicjaycommented, Jul 4, 2023

To the MAUI team, I am sorry but this is not a “move to backlog” issue. This is critical. I was shocked to see this issue was created back in November with no response since.

  1. DIsplaying lists is a very common app function.
  2. Sending apps to the background is a very common user action.

One might recommend that we could use CollectionView, but frankly, that also has a whole separate set of issues that made me switch back to ListView.

3reactions
HealthModecommented, Jun 20, 2023

I was struggling with this issue and CachingStrategy="RecycleElement" fixed it on the XAML of the list view

Read more comments on GitHub >

github_iconTop Results From Across the Web

IOS TableView have more than 2 ViewCell , app come ...
Only IOS and more than 2 viewcell have this problem. ... ListView ViewCell content disappears when the application enters the foreground ...
Read more >
xaml - MAUI Bug ListView content disappeared by using ...
2 Answers. An efficient solution is to not set the property until the list is filled. Create the list in a local variable;...
Read more >
Xamarin.Forms — Xamarin Community Forums
It works great in the foreground, but when the app is backgrounded, the service pauses until the app comes to the foreground again....
Read more >
sitemap7.xml
... daily 0.0001 https://www.telerik.com/forums/change-html-in-listview-elements-created-using-a-template-with-ajax-in-asp-net-mvc-4-application ...
Read more >
[Resolve]-Xamarin.Forms ListView ViewCell issue on iOS
I've been trying to get this looking right in Xaml (x.forms) but can't make it work. Any possibly way this can be solved...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found