maui
maui copied to clipboard
Hot Reload (and C# code updates) doesn't update Children of ListView on WinUI
Description
Updating a ListView item template doesn't update the UI, on WinUI, when using Hot Reload. Updating with C# code behind doesn't seem to work either. Android and iOS work - this issue looks to be WinUI specific.
Steps to Reproduce
- Do File / New Project / MAUI
- Replace the ContentPage content in MainPage.xaml with the XAML below. Note that this is a
ListViewwith a simpleItemTemplate, with two items in the list - Run the app, on WinUI
- Update the Label, say changing the
TextfromHellotoHi
Result: Nothing changes - the WinUI UI doesn't update Expected: Hot Reload should work here.
Note: Per @drasticactions, it works on Android and iOS, just not WinUI. Poking the same values from code behind in C# for WinUI shows it doesn't there either. The View Children are now being populated with the implementation of IVisualTreeElement, but updating the underlying children elements in WinUI does not update the UI.
<ScrollView>
<ListView>
<ListView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>dummyitem1</x:String>
<x:String>dummyitem2</x:String>
</x:Array>
</ListView.ItemsSource>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Label Text="Hello" />
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ScrollView>
Link to public reproduction project repository
not needed - see description for XAML
Version with bug
6.0.312
Last version that worked well
6.0.312
Affected platforms
Windows
Affected platform versions
.NET7 with VS 17.5
Did you find any workaround?
no
Relevant log output
No response
We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

The Logical Children are 0.
Some notes:
- LogicalChildren for ListView is always 0 for WinUI, I am trying to untangle it but I believe this is why:
- The ListViewHandler, renderer that handles ListView on Windows, has its underlying WinUI ListView ItemsSource context set to whatever the user has set to the above MAUI version.
- That then generates new cells, which call for whatever the MAUI DataTemplate is to be applied to the underlying item. That then kicks off MAUIs handler implementation for the individual cell.
- The MAUI cells are then applied to the WinUI Cell, showing the MAUI generated UI.
- MAUI does not track these cells internally. WinUI calls for new/old cells and MAUI then generates or removes them as needed.
- As a result, none of these MAUI views are being tracked internally by the ListViewRenderer, or exposed in ListView itself. The views that are listed in ListView that would add/remove logical children (SetupContent, etc) are never called on WinUI.
Hi @BretJohnson. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.
You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
@drasticactions @PureWeen I tested with maui main and this is still broken - no ListView children show in the LVT nor does Hot Reload work when updating the template.
one option would be to invalidate the full view when the item template change...
Weirdly enough hot reload seems to work fine with CollectionView. Additionally, if you select an item in the ListView then it does add the children in the live visual tree, but hot reload still doesn't work.
@Foda That's because of https://github.com/dotnet/maui/issues/18401, which I think is the underlying issue.
- Hot Reload works with CollectionView because it exposes its children elements. Since those appear in LogicalChildren, they can be registered by the Live Visual Tree, so they appear available in Hot Reload.
- ListView doesn't do that for WinUI. Logical Children are empty. That's because of how the Cells are created (both by the initial rendering of the view, and when new items are added and removed), which is https://github.com/dotnet/maui/issues/18401. The initial item list that's generated are not being registered to LVT and are being created directly by the List View Renderer and stored internally. New items that are added after the fact are being registered, because they're being created twice, and the one registered to LVT is not being rendered on screen.
If you fix https://github.com/dotnet/maui/issues/18401, then this should work.