diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/CollectionViewGallery.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/CollectionViewGallery.cs
index beaa8b4b78da..a810a470223a 100644
--- a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/CollectionViewGallery.cs
+++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/CollectionViewGallery.cs
@@ -50,6 +50,7 @@ public CollectionViewGallery()
GalleryBuilder.NavButton("Alternate Layout Galleries", () => new AlternateLayoutGallery(), Navigation),
GalleryBuilder.NavButton("Header/Footer Galleries", () => new HeaderFooterGallery(), Navigation),
GalleryBuilder.NavButton("Nested CollectionViews", () => new NestedGalleries.NestedCollectionViewGallery(), Navigation),
+ GalleryBuilder.NavButton("Online images", () => new OnlineImages(), Navigation),
}
}
};
diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/OnlineImages.xaml b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/OnlineImages.xaml
new file mode 100644
index 000000000000..652d71bbc66d
--- /dev/null
+++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/OnlineImages.xaml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/OnlineImages.xaml.cs b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/OnlineImages.xaml.cs
new file mode 100644
index 000000000000..653f6ef22124
--- /dev/null
+++ b/src/Controls/samples/Controls.Sample/Pages/Controls/CollectionViewGalleries/OnlineImages.xaml.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.ObjectModel;
+using System.Threading.Tasks;
+using Microsoft.Maui.Controls;
+using Microsoft.Maui.Controls.Xaml;
+using Microsoft.Maui.Dispatching;
+
+namespace Maui.Controls.Sample.Pages.CollectionViewGalleries
+{
+ public record OnlineImageInfo(string Uri);
+
+ [XamlCompilation(XamlCompilationOptions.Compile)]
+ public partial class OnlineImages : ContentPage
+ {
+ public OnlineImages()
+ {
+ InitializeComponent();
+
+ Dispatcher.DispatchAsync(SetItemsSource);
+ }
+
+ async Task SetItemsSource()
+ {
+ await Task.Delay(TimeSpan.FromSeconds(1));
+
+ CollectionView.ItemsSource = new ObservableCollection
+ {
+ new ("https://news.microsoft.com/wp-content/uploads/prod/2022/07/hexagon_print.gif"),
+ new ("https://news.microsoft.com/wp-content/uploads/prod/2022/07/collaboration-controls-in-power-platform_print.gif"),
+ new ("https://news.microsoft.com/wp-content/uploads/prod/2022/07/Updatesin-Teams.png"),
+ new ("https://news.microsoft.com/wp-content/uploads/prod/2022/07/Expanded-Reactions.png"),
+ new ("https://news.microsoft.com/wp-content/uploads/prod/2022/04/Companion-Devices.jpg"),
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Platform/Windows/CollectionView/ItemContentControl.cs b/src/Controls/src/Core/Platform/Windows/CollectionView/ItemContentControl.cs
index 8c43146a8b6d..c6181e05d028 100644
--- a/src/Controls/src/Core/Platform/Windows/CollectionView/ItemContentControl.cs
+++ b/src/Controls/src/Core/Platform/Windows/CollectionView/ItemContentControl.cs
@@ -168,7 +168,6 @@ internal void Realize()
// or if we need to switch DataTemplates (because this instance is being recycled)
// then we'll need to create the content from the template
_visualElement = formsTemplate.CreateContent(dataContext, container) as VisualElement;
- _visualElement.BindingContext = dataContext;
_renderer = _visualElement.ToHandler(mauiContext);
// We need to set IsPlatformStateConsistent explicitly; otherwise, it won't be set until the renderer's Loaded
@@ -186,11 +185,11 @@ internal void Realize()
{
// We are reusing this ItemContentControl and we can reuse the Element
_visualElement = _renderer.VirtualView as VisualElement;
- _visualElement.BindingContext = dataContext;
}
Content = _renderer.ToPlatform();
itemsView?.AddLogicalChild(_visualElement);
+ _visualElement.BindingContext = dataContext;
}
void SetNativeStateConsistent(VisualElement visualElement)