Open SkyeHoefling opened 3 years ago
Thanks for the report.
This could be an Image issue, not a ListView issue. What happens if you bind the image url to a textblock ? Does it appear ?
/cc @davidjohnoliver
In the reproduction project I am not binding the image it is a hard-coded value for the source. See the DataTemplate
below:
<DataTemplate x:Key="MyItemTemplate">
<StackPanel Spacing="20" Width="175" Height="250">
<Image Source="ms-appx:///Assets/Images/folder.png" />
<TextBlock
Text="{Binding Name}"
HorizontalAlignment="Center"
HorizontalTextAlignment="Center"
TextWrapping="WrapWholeWords" />
</StackPanel>
</DataTemplate>
Current behavior
When using an
ObservableCollection
with aGridView
control the 1st item in theItemsSource
doesn't render images correctly when loaded sequentially. For example if you have aDataTemplate
that displays an image and text the first one will just have the text where the remaining items will all render correctly with the image and text.To the best of my knowledge this only happens with
ObservableCollection<T>
and doesn't happen if you update the entireItemsSource
at once.Android Screenshot Notice in the screenshot below the first folder image is missing
UWP Rendering Notice all items are rendered correctly
The code in question is loading data and adding 1 item at a time to the
ObservableCollection<T>
. This is a common practice when usingObservableCollection<T>
.Expected behavior
I expect the Android platform to render the 1st item just like every other item with the folder image and the text below.
How to reproduce it (as minimally and precisely as possible)
I have attached a minimal project that reproduces this issue on Android
Workaround
My workaround is to not use an
ObservableCollection<T>
but to just aList<T>
and when I'm done loading the data fire theINotifyPropertyChanged
for the entire collection. This will update the entire collection of theItemsSource
on theGridView
.Performance Considerations If you are working with a large data set and are adding 1 item at a time this isn't a good option as it will reload the entire
GridView
with every update. You may be able to use anObservableCollection
in this fashion for first load then do incremental changes, but I haven't tested it.Works on UWP/WinUI
yes
Environment
Nuget Package:
Nuget Package Version(s): 3.8.11
Affected platform(s):
IDE:
Relevant plugins:
Anything else we need to know?
N/A