@@ -59,21 +59,49 @@ protected override Size ArrangeOverride(NonVirtualizingLayoutContext context, Si
5959 {
6060 double accumulatedWidths = 0d ;
6161
62- _indexAfterEllipsis = context . Children . Count - 1 ;
62+ _indexAfterEllipsis = GetFirstIndexToRender ( context ) ;
6363
6464 // Go through all items and arrange them
65+ int index = 0 ;
6566 foreach ( var item in context . Children )
6667 {
6768 if ( item is BreadcrumbBarItem breadcrumbItem )
6869 {
69- breadcrumbItem . Arrange ( new Rect ( accumulatedWidths , 0 , breadcrumbItem . DesiredSize . Width , breadcrumbItem . DesiredSize . Height ) ) ;
70+ if ( index < _indexAfterEllipsis )
71+ {
72+ breadcrumbItem . Arrange ( new Rect ( 0 , 0 , 0 , 0 ) ) ;
73+ }
74+ else
75+ {
76+ breadcrumbItem . Arrange ( new Rect ( accumulatedWidths , 0 , breadcrumbItem . DesiredSize . Width , breadcrumbItem . DesiredSize . Height ) ) ;
7077
71- accumulatedWidths += breadcrumbItem . DesiredSize . Width ;
72- accumulatedWidths += _spacing ;
78+ accumulatedWidths += breadcrumbItem . DesiredSize . Width ;
79+ accumulatedWidths += _spacing ;
80+ }
81+
82+ index ++ ;
7383 }
7484 }
7585
7686 return finalSize ;
7787 }
88+
89+ private int GetFirstIndexToRender ( NonVirtualizingLayoutContext context )
90+ {
91+ var itemCount = context . Children . Count ;
92+ var accumulatedWidth = context . Children [ itemCount - 1 ] . DesiredSize . Width ;
93+
94+ for ( int i = itemCount - 2 ; i >= 0 ; i -- )
95+ {
96+ var newAccumulatedWidth = accumulatedWidth + context . Children [ i ] . DesiredSize . Width ;
97+
98+ if ( newAccumulatedWidth > _availableSize . Width )
99+ return i + 1 ;
100+
101+ accumulatedWidth = newAccumulatedWidth ;
102+ }
103+
104+ return 0 ;
105+ }
78106 }
79107}
0 commit comments