Open sstahurski opened 1 year ago
I am also having this issue, and I have found that others have been experiencing this problem with ListViews since last year. I am trying to come up with a workaround. I tried changing the Caching Strategy, calling InvalidateMeasure on the ListView, and adding items with delays in between adds.
foreach(var item in MyCollection) { MyObservableCollection.Add(item); Task.Delay(100); }
None of the above worked, and even when the caching strategy was set to RetainElement, and there was a significant delay between item adds, I could watch the app add completely blank items to the ListView.
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Just thought I'd follow up with how I overcame this for anyone looking at this in the future. I ditched the ListView and made my own equivalent. It works fine for now, but I get some .Dispose()
warnings in the console.
XAML:
<ScrollView VerticalOptions="FillAndExpand"> <StackLayout x:Name="ItemsLayout" VerticalOptions="FillAndExpand"> </StackLayout> </ScrollView>
C#:
private void ClearAndFillItemsList()
{
ItemsLayout.Children.Clear();
foreach(var item in viewModel.Items)
{
AddItemToLayout(item);
}
}
private void AddItemToLayout(ItemType item)
{
ItemsLayout.Children.Add(new CustomViewDataType(item));
}
I call ClearAndFillItemsList()
in a Refresh method.
The items I'm adding to ItemsLayout have their own DataType inheriting from ContentView
. I have my gesture handlers in that code and XAML to handle when items are tapped.
Hope this helps out.
Just thought I'd follow up with how I overcame this for anyone looking at this in the future. I ditched the ListView and made my own equivalent. It works fine for now, but I get some
.Dispose()
warnings in the console.XAML:
<ScrollView VerticalOptions="FillAndExpand"> <StackLayout x:Name="ItemsLayout" VerticalOptions="FillAndExpand"> </StackLayout> </ScrollView>
C#:
private void ClearAndFillItemsList() { ItemsLayout.Children.Clear(); foreach(var item in viewModel.Items) { AddItemToLayout(item); } } private void AddItemToLayout(ItemType item) { ItemsLayout.Children.Add(new CustomViewDataType(item)); }
I call
ClearAndFillItemsList()
in a Refresh method.The items I'm adding to ItemsLayout have their own DataType inheriting from
ContentView
. I have my gesture handlers in that code and XAML to handle when items are tapped.Hope this helps out.
Hey, can you publish the repo of the workaround? I am strugling with this too, it happens on MacOS app.
Verified this issue with Visual Studio Enterprise 17.7.0 Preview 1.0. Can repro on iOS platform with sample project. testListView
Description
I have a content page with a bindable context, a view model with an observable collection. I've tried different types of views ( Listview, scrollable stackview,etc) and the ObservableCollection does not return the values in to the views for the views and subviews at times.
This occurs when scrolling and when the user selects the home button on ios, and then brings the app back to the foreground. The first image is when the app initially comes up, the second is when the app is placed in the background ( home button) and then is brought to the foreground. I have also seen this occur when just scrolling the list.
Steps to Reproduce
ALT
Link to public reproduction project repository
https://github.com/sstahurski/testListView
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
ios 16.2
Did you find any workaround?
no workaround.
Relevant log output
No response