ListView ViewCell content disappears when the application enters the foreground
See original GitHub issueDescription
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
- Create a New .NET MAUI App from the template
- 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>
- Run the app on iOS Simulator 16.0. The app shows a list with three lines of buttons.
- Send the app to the background. Do not close the app!
- 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:
- Created 10 months ago
- Reactions:9
- Comments:26 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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.
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.
I was struggling with this issue and
CachingStrategy="RecycleElement"fixed it on the XAML of the list view