dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.96k stars 1.7k forks source link

Hot Reload (and C# code updates) doesn't update Children of ListView on WinUI #13900

Open BretJohnson opened 1 year ago

BretJohnson commented 1 year ago

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

  1. Do File / New Project / MAUI
  2. Replace the ContentPage content in MainPage.xaml with the XAML below. Note that this is a ListView with a simple ItemTemplate, with two items in the list
  3. Run the app, on WinUI
  4. Update the Label, say changing the Text from Hello to Hi

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

ghost commented 1 year ago

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.

drasticactions commented 1 year ago

image

The Logical Children are 0.

drasticactions commented 1 year ago

Some notes:

ghost commented 1 year ago

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.

BretJohnson commented 1 year ago

@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.

image

StephaneDelcroix commented 7 months ago

one option would be to invalidate the full view when the item template change...

Foda commented 7 months ago

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.

drasticactions commented 7 months ago

@Foda That's because of https://github.com/dotnet/maui/issues/18401, which I think is the underlying issue.

If you fix https://github.com/dotnet/maui/issues/18401, then this should work.