@@ -580,6 +580,64 @@ public void ValidateGridLayoutMaximumRowsOrColumns()
580580 } ) ;
581581 }
582582
583+ [ TestMethod ]
584+ public void ValidateGridLayoutDesiredSizingWithMaxRowsOrColumnsSet ( )
585+ {
586+ RunOnUIThread . Execute ( ( ) =>
587+ {
588+ foreach ( ScrollOrientation scrollOrientation in Enum . GetValues ( typeof ( ScrollOrientation ) ) )
589+ {
590+ Log . Comment ( string . Format ( "ScrollOrientation: {0}" , scrollOrientation ) ) ;
591+ var om = new OrientationBasedMeasures ( scrollOrientation , useLayoutRounding : true ) ;
592+ const int numItems = 4 ;
593+
594+ int itemSize = 100 ;
595+
596+ LayoutPanel panel = new LayoutPanel ( ) ;
597+ var layout = new UniformGridLayout ( ) {
598+ Orientation = scrollOrientation . ToOrthogonalLayoutOrientation ( ) ,
599+ ItemsJustification = UniformGridLayoutItemsJustification . Start ,
600+ MinItemWidth = itemSize ,
601+ MinItemHeight = itemSize ,
602+ MinRowSpacing = 0 ,
603+ MinColumnSpacing = 0
604+ } ;
605+
606+ for ( int i = 0 ; i < numItems ; i ++ )
607+ {
608+ panel . Children . Add ( new Button ( ) { Content = i , Width = itemSize , Height = itemSize } ) ;
609+ }
610+
611+ panel . Layout = layout ;
612+ Content = panel ;
613+
614+ // Place in top left corner to prevent stretch of panel
615+ panel . VerticalAlignment = VerticalAlignment . Top ;
616+ panel . HorizontalAlignment = HorizontalAlignment . Left ;
617+ layout . ItemsJustification = UniformGridLayoutItemsJustification . Start ;
618+
619+ for ( int i = 1 ; i < numItems ; i ++ )
620+ {
621+ layout . MaximumRowsOrColumns = i ;
622+ panel . UpdateLayout ( ) ;
623+
624+ if ( om . IsVerical )
625+ {
626+ // Vertical so fill columns first
627+ Verify . AreEqual ( itemSize * i , panel . DesiredSize . Width ) ;
628+ Verify . AreEqual ( Math . Ceiling ( ( double ) numItems / ( double ) i ) * itemSize , panel . DesiredSize . Height ) ;
629+ }
630+ else
631+ {
632+ // Horizontal, fill rows first
633+ Verify . AreEqual ( itemSize * i , panel . DesiredSize . Height ) ;
634+ Verify . AreEqual ( Math . Ceiling ( ( double ) numItems / ( double ) i ) * itemSize , panel . DesiredSize . Width ) ;
635+ }
636+ }
637+
638+ }
639+ } ) ;
640+ }
583641
584642 [ TestMethod ]
585643 public void ValidateFlowLayout ( )
0 commit comments