File tree Expand file tree Collapse file tree 1 file changed +18
-10
lines changed
src/Uno.UI/UI/Xaml/Controls/Canvas Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -21,20 +21,28 @@ partial void InitializePartial()
21
21
22
22
partial void MeasureOverridePartial ( )
23
23
{
24
- if ( _drawOrders ? . Length != Children . Count )
24
+ // Sorting is only needed when Children count is above 1
25
+ if ( Children . Count > 1 )
25
26
{
26
- _drawOrders = new int [ Children . Count ] ;
27
- }
27
+ if ( _drawOrders ? . Length != Children . Count )
28
+ {
29
+ _drawOrders = new int [ Children . Count ] ;
30
+ }
28
31
29
- var sorted = Children
30
- . Select ( ( view , childrenIndex ) => ( view , childrenIndex ) )
31
- . OrderBy ( tpl => tpl . view is DependencyObject obj ? Canvas . GetZIndex ( obj ) : 0 ) ; // Note: this has to be a stable sort
32
+ var sorted = Children
33
+ . Select ( ( view , childrenIndex ) => ( view , childrenIndex ) )
34
+ . OrderBy ( tpl => tpl . view is DependencyObject obj ? Canvas . GetZIndex ( obj ) : 0 ) ; // Note: this has to be a stable sort
32
35
33
- var drawOrder = 0 ;
34
- foreach ( var tpl in sorted )
36
+ var drawOrder = 0 ;
37
+ foreach ( var tpl in sorted )
38
+ {
39
+ _drawOrders [ tpl . childrenIndex ] = drawOrder ;
40
+ drawOrder ++ ;
41
+ }
42
+ }
43
+ else
35
44
{
36
- _drawOrders [ tpl . childrenIndex ] = drawOrder ;
37
- drawOrder ++ ;
45
+ _drawOrders = null ;
38
46
}
39
47
}
40
48
You can’t perform that action at this time.
0 commit comments