Edited
In a WinUI3 project, the below XAML GridView code works perfectly fine. The UI in UserHomeView gets generated, and all of the properties and processes dependent on UserHomeViewModel get triggered and updated. However, as soon as I replace StackPanel by ItemsWrapGrid to have the items arranged in a grid, it stops working, I still can see the UI from UserHomeView for every item but UserHomeViewModel is null and the rendered UI for each item is not usable at all.
-Works fine.
<GridView ItemsSource="{x:Bind WindowConfiguratorViewModel.KioskCollection, Mode=OneWay}">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel /> <!--Working!-->
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemTemplate>
<DataTemplate x:DataType="viewModelsConfigurator:ProfileKioskDesktopViewModel">
<userHomeViews:UserHomeView UserHomeViewModel="{x:Bind UserHomeViewModel}" />
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
-Does not work.
<GridView ItemsSource="{x:Bind WindowConfiguratorViewModel.KioskCollection, Mode=OneWay}">
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid /><!--Not Working!-->
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.ItemTemplate>
<DataTemplate x:DataType="viewModelsConfigurator:ProfileKioskDesktopViewModel">
<userHomeViews:UserHomeView UserHomeViewModel="{x:Bind UserHomeViewModel}" />
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
I tested with other custom views in user controls and the results are the same. I don't get neither compilation nor runtime errors, the UserHomeViewModel simply does not bind when using ItemsWrapGrid.
Does anybody know why this happens?
Update
I created a minimal reproduction of the issue here https://github.com/hclazarin/DesktopManager
ListView.ItemTemplate?ListViewcompiles and all items are rendered, however, theUserHomeViewModelproperty in each one of the resulting items isnull. When I add the items to theListViewmanually by usingListViewIteminstead of through a template theUserHomeViewModelproperty is correctly assigned, it's notnull, of course, this is not functional since the list will grow as the user interacts with the app.