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
22.26k stars 1.76k forks source link

Grid: Not getting invalidated when changing the Height/Width of Row/ColumnDefinitions declared with the short syntax #25983

Open eli-popova opened 3 days ago

eli-popova commented 3 days ago

Description

When declaring the RowDefinitions of a grid using the short syntax and then changing the Height property of a row, the grid doesn't get invalidated and the change takes effect after some other action invalidates the grid - for example if the window is resized (same for ColumnDefinitions).

Looking at: https://github.com/dotnet/maui/blob/main/src/Controls/src/Core/RowDefinitionCollectionTypeConverter.cs#L31 and https://github.com/dotnet/maui/blob/main/src/Controls/src/Core/DefinitionCollection.cs#L15 the SizeChanged event isn't triggered in this case, whereas adding the rows one by one triggers the SizeChanged event - https://github.com/dotnet/maui/blob/main/src/Controls/src/Core/DefinitionCollection.cs#L21.

I believe we should have the same behavior when using the short syntax for Row/ColumnDefinitions.

Steps to Reproduce

  1. Run the project
  2. Click the Resize button
  3. Observation: The blue row doesn't change its height
  4. Expected: The blue row to increase its height
  5. Comment the first grid with RowDefinitions declared with the short xaml syntax
  6. Uncomment the second grid
  7. Click the Resize button
  8. Observation: The blue row's height is increased as expected

Link to public reproduction project repository

https://github.com/telerik/ms-samples/tree/main/Maui/GridRowsShortSyntaxIssue

Version with bug

9.0.0 GA

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android, Windows, macOS

Affected platform versions

No response

Did you find any workaround?

Call InvalidateMeasure after changing the value of Height/Width of Row/ColumnDefinitions.

Note: This may not fully cover everything that is missing out.

Relevant log output

ninachen03 commented 2 days ago

This issue has been verified using Visual Studio 17.13.0 Preview 1.0 (9.0.10 & 9.0.0 & 8.0.100 &8.0.3). Can repro it.