Chris
Chris

Reputation: 545

Hot Reload not working properly with some tags? (ViewCell/DataTemplate)

I have this XAML

<Label Text="Logfile" FontAttributes="Bold" Margin="0,0,0,10" />
<ListView ItemsSource="{Binding LogEntries}">
  <ListView.ItemTemplate>
    <DataTemplate  x:DataType="model:LogEntity">
      <ViewCell>
        <Grid RowDefinitions="*,*" BackgroundColor="Blue">
        
          <Label Text="{Binding Message}" Grid.Row="0"></Label>
          <Label Text="{Binding  LogTime}" Grid.Row="1"></Label>
        
        </Grid>
      </ViewCell>
    </DataTemplate>
  </ListView.ItemTemplate>
</ListView>

If I change these tags

<Label Text="Logfile" FontAttributes="Bold" Margin="0,0,0,10" />
<ListView ItemsSource="{Binding LogEntries}">

the changes appear immediately in the app. But when I change anything within this tag

<ViewCell>
  <Grid RowDefinitions="*,*" BackgroundColor="Blue">
            
    <Label Text="{Binding Message}" Grid.Row="0"></Label>
    <Label Text="{Binding  LogTime}" Grid.Row="1"></Label>
            
  </Grid>
</ViewCell>

nothing happens.

Are there any known limitations to this? Maybe because it's inside a DataTemplate? I haven't seen any limitation in this regards over here: https://learn.microsoft.com/en-us/visualstudio/xaml-tools/xaml-hot-reload-troubleshooting?view=vs-2022

I am using Visual Studio 2022 Version 17.3.0 Preview 1.1.

My settings in Visual Studio are:

Debugging -> .NET/C++ Hot Reload (Probably not relevant for this context)

Debugging -> XAML Hot Reload

I am debugging as Windows App on a Windows machine (Windows 10 Home, 21H2).

Under View -> Output -> Xamarin Hot Reload, when I make a change to the "Label" tag, it says:

[12:34:18 PM] Applying XAML Hot Reload update

When I make a change within the "ViewCell", nothing happens in the output window.

Workaround: While writing this, I noticed a workaround:

This is certainly something I can live with for a while, but it would be great to not have to apply any workarounds for this.

Upvotes: 2

Views: 809

Answers (1)

Lugano
Lugano

Reputation: 1

The problem should be the ViewCell of the ListView. If you use a CollectionView and define your own template, hot reload will work as it should.

You can find an example of CollectionView at Specify CollectionView layout

Upvotes: 0

Related Questions