@@ -84,6 +84,26 @@ private static bool IsWidthHeightValid(object value)
8484 return double . IsNaN ( v ) || v >= 0.0d && ! double . IsPositiveInfinity ( v ) ;
8585 }
8686
87+ public static readonly DependencyProperty ItemHorizontalAlignmentProperty = DependencyProperty . Register (
88+ "ItemHorizontalAlignment" , typeof ( HorizontalAlignment ? ) , typeof ( UniformSpacingPanel ) ,
89+ new FrameworkPropertyMetadata ( HorizontalAlignment . Stretch , FrameworkPropertyMetadataOptions . AffectsMeasure ) ) ;
90+
91+ public HorizontalAlignment ? ItemHorizontalAlignment
92+ {
93+ get => ( HorizontalAlignment ? ) GetValue ( ItemHorizontalAlignmentProperty ) ;
94+ set => SetValue ( ItemHorizontalAlignmentProperty , value ) ;
95+ }
96+
97+ public static readonly DependencyProperty ItemVerticalAlignmentProperty = DependencyProperty . Register (
98+ "ItemVerticalAlignment" , typeof ( VerticalAlignment ? ) , typeof ( UniformSpacingPanel ) ,
99+ new FrameworkPropertyMetadata ( VerticalAlignment . Stretch , FrameworkPropertyMetadataOptions . AffectsMeasure ) ) ;
100+
101+ public VerticalAlignment ? ItemVerticalAlignment
102+ {
103+ get => ( VerticalAlignment ? ) GetValue ( ItemVerticalAlignmentProperty ) ;
104+ set => SetValue ( ItemVerticalAlignmentProperty , value ) ;
105+ }
106+
87107 private void ArrangeWrapLine ( double v , double lineV , int start , int end , bool useItemU , double itemU , double spacing )
88108 {
89109 double u = 0 ;
@@ -100,7 +120,10 @@ private void ArrangeWrapLine(double v, double lineV, int start, int end, bool us
100120
101121 child . Arrange ( isHorizontal ? new Rect ( u , v , layoutSlotU , lineV ) : new Rect ( v , u , lineV , layoutSlotU ) ) ;
102122
103- u += layoutSlotU + spacing ;
123+ if ( layoutSlotU > 0 )
124+ {
125+ u += layoutSlotU + spacing ;
126+ }
104127 }
105128 }
106129
@@ -120,7 +143,10 @@ private void ArrangeLine(double lineV, bool useItemU, double itemU, double spaci
120143
121144 child . Arrange ( isHorizontal ? new Rect ( u , 0 , layoutSlotU , lineV ) : new Rect ( 0 , u , lineV , layoutSlotU ) ) ;
122145
123- u += layoutSlotU + spacing ;
146+ if ( layoutSlotU > 0 )
147+ {
148+ u += layoutSlotU + spacing ;
149+ }
124150 }
125151 }
126152
@@ -135,6 +161,10 @@ protected override Size MeasureOverride(Size constraint)
135161 var itemHeightSet = ! double . IsNaN ( itemHeight ) ;
136162 var spacing = Spacing ;
137163 var childWrapping = ChildWrapping ;
164+ var itemHorizontalAlignment = ItemHorizontalAlignment ;
165+ var itemVerticalAlignment = ItemVerticalAlignment ;
166+ var itemHorizontalAlignmentSet = itemHorizontalAlignment != null ;
167+ var itemVerticalAlignmentSet = ItemVerticalAlignment != null ;
138168
139169 var childConstraint = new Size (
140170 itemWidthSet ? itemWidth : constraint . Width ,
@@ -150,6 +180,16 @@ protected override Size MeasureOverride(Size constraint)
150180 var child = children [ i ] ;
151181 if ( child == null ) continue ;
152182
183+ if ( itemHorizontalAlignmentSet )
184+ {
185+ child . SetCurrentValue ( HorizontalAlignmentProperty , itemHorizontalAlignment ) ;
186+ }
187+
188+ if ( itemVerticalAlignmentSet )
189+ {
190+ child . SetCurrentValue ( VerticalAlignmentProperty , itemVerticalAlignment ) ;
191+ }
192+
153193 child . Measure ( childConstraint ) ;
154194
155195 var sz = new UVSize (
@@ -199,6 +239,16 @@ protected override Size MeasureOverride(Size constraint)
199239 var child = children [ i ] ;
200240 if ( child == null ) continue ;
201241
242+ if ( itemHorizontalAlignmentSet )
243+ {
244+ child . SetCurrentValue ( HorizontalAlignmentProperty , itemHorizontalAlignment ) ;
245+ }
246+
247+ if ( itemVerticalAlignmentSet )
248+ {
249+ child . SetCurrentValue ( VerticalAlignmentProperty , itemVerticalAlignment ) ;
250+ }
251+
202252 child . Measure ( layoutSlotSize ) ;
203253
204254 var sz = new UVSize (
0 commit comments