File tree Expand file tree Collapse file tree 4 files changed +47
-21
lines changed Expand file tree Collapse file tree 4 files changed +47
-21
lines changed Original file line number Diff line number Diff line change @@ -3336,16 +3336,15 @@ protected override Size MeasureOverride(Size availableSize)
3336
3336
}
3337
3337
else
3338
3338
{
3339
- #if ! HAS_UNO
3340
- // This section is commented out in Uno until the measure
3341
- // loop in uno is adressed
3342
- if ( _rowsPresenter != null )
3339
+ if ( DataGridFeatureConfiguation . EnableInvalidateMeasureInMeasureOverride )
3343
3340
{
3344
- _rowsPresenter . InvalidateMeasure ( ) ;
3345
- }
3341
+ if ( _rowsPresenter != null )
3342
+ {
3343
+ _rowsPresenter . InvalidateMeasure ( ) ;
3344
+ }
3346
3345
3347
- InvalidateColumnHeadersMeasure ( ) ;
3348
- #endif
3346
+ InvalidateColumnHeadersMeasure ( ) ;
3347
+ }
3349
3348
3350
3349
desiredSize = base . MeasureOverride ( availableSize ) ;
3351
3350
Original file line number Diff line number Diff line change
1
+ // Licensed to the .NET Foundation under one or more agreements.
2
+ // The .NET Foundation licenses this file to you under the MIT license.
3
+ // See the LICENSE file in the project root for more information.
4
+
5
+ namespace CommunityToolkit . WinUI . UI . Controls
6
+ {
7
+ /// <summary>
8
+ /// Uno-specific feature configuration
9
+ /// </summary>
10
+ public static class DataGridFeatureConfiguation
11
+ {
12
+ /// <summary>
13
+ /// Gets or sets a value indicating whether if InvalidateMeasure invocations can be done in MeasureOverride locations.
14
+ /// </summary>
15
+ /// <remarks>
16
+ /// This configuration is required until https://github.com/unoplatform/uno/issues/3519 is fixed. Without this
17
+ /// the layout engine turns into a loop and consumes CPU excessively, or freezes the app.
18
+ /// </remarks>
19
+ public static bool EnableInvalidateMeasureInMeasureOverride { get ; set ; } = false ;
20
+ }
21
+ }
Original file line number Diff line number Diff line change @@ -780,20 +780,23 @@ protected override Size MeasureOverride(Size availableSize)
780
780
return base . MeasureOverride ( availableSize ) ;
781
781
}
782
782
783
- // Allow the DataGrid specific components to adjust themselves based on new values
784
- if ( _headerElement != null )
783
+ if ( DataGridFeatureConfiguation . EnableInvalidateMeasureInMeasureOverride )
785
784
{
786
- _headerElement . InvalidateMeasure ( ) ;
787
- }
785
+ // Allow the DataGrid specific components to adjust themselves based on new values
786
+ if ( _headerElement != null )
787
+ {
788
+ _headerElement . InvalidateMeasure ( ) ;
789
+ }
788
790
789
- if ( _cellsElement != null )
790
- {
791
- _cellsElement . InvalidateMeasure ( ) ;
792
- }
791
+ if ( _cellsElement != null )
792
+ {
793
+ _cellsElement . InvalidateMeasure ( ) ;
794
+ }
793
795
794
- if ( _detailsElement != null )
795
- {
796
- _detailsElement . InvalidateMeasure ( ) ;
796
+ if ( _detailsElement != null )
797
+ {
798
+ _detailsElement . InvalidateMeasure ( ) ;
799
+ }
797
800
}
798
801
799
802
bool currentAddItemIsDataContext = false ;
Original file line number Diff line number Diff line change @@ -133,9 +133,12 @@ protected override Size MeasureOverride(Size availableSize)
133
133
DataGridRow row = element as DataGridRow ;
134
134
if ( row != null )
135
135
{
136
- if ( invalidateRows )
136
+ if ( DataGridFeatureConfiguation . EnableInvalidateMeasureInMeasureOverride )
137
137
{
138
- row . InvalidateMeasure ( ) ;
138
+ if ( invalidateRows )
139
+ {
140
+ row . InvalidateMeasure ( ) ;
141
+ }
139
142
}
140
143
}
141
144
You can’t perform that action at this time.
0 commit comments