@@ -55,42 +55,6 @@ public double VerticalSpacing
5555 typeof ( WrapPanel ) ,
5656 new PropertyMetadata ( 0d , LayoutPropertyChanged ) ) ;
5757
58- /// <summary>
59- /// Gets or sets the vertical alignment to use when the control <see cref="Orientation"/> is set to <see cref="Orientation.Horizontal"/>.
60- /// </summary>
61- public VerticalAlignment VerticalContentAlignment
62- {
63- get => ( VerticalAlignment ) GetValue ( VerticalContentAlignmentProperty ) ;
64- set => SetValue ( VerticalContentAlignmentProperty , value ) ;
65- }
66-
67- /// <summary>
68- /// The DP to store the <see cref="VerticalContentAlignment"/> property value.
69- /// </summary>
70- public static readonly DependencyProperty VerticalContentAlignmentProperty = DependencyProperty . Register (
71- nameof ( VerticalContentAlignment ) ,
72- typeof ( VerticalAlignment ) ,
73- typeof ( WrapPanel ) ,
74- new PropertyMetadata ( VerticalAlignment . Top , LayoutPropertyChanged ) ) ;
75-
76- /// <summary>
77- /// Gets or sets the horizontal alignment to use when the control <see cref="Orientation"/> is set to <see cref="Orientation.Vertical"/>.
78- /// </summary>
79- public HorizontalAlignment HorizontalContentAlignment
80- {
81- get => ( HorizontalAlignment ) GetValue ( HorizontalContentAlignmentProperty ) ;
82- set => SetValue ( HorizontalContentAlignmentProperty , value ) ;
83- }
84-
85- /// <summary>
86- /// The DP to store the <see cref="HorizontalContentAlignment"/> property value.
87- /// </summary>
88- public static readonly DependencyProperty HorizontalContentAlignmentProperty = DependencyProperty . Register (
89- nameof ( HorizontalContentAlignment ) ,
90- typeof ( HorizontalAlignment ) ,
91- typeof ( WrapPanel ) ,
92- new PropertyMetadata ( HorizontalAlignment . Left , LayoutPropertyChanged ) ) ;
93-
9458 /// <summary>
9559 /// Gets or sets the orientation of the WrapPanel.
9660 /// Horizontal means that child controls will be added horizontally until the width of the panel is reached, then a new row is added to add new child controls.
@@ -301,11 +265,13 @@ void Arrange(UIElement child, bool isLast = false)
301265 UvRect arrangeRect ;
302266 if ( Orientation == Orientation . Horizontal )
303267 {
304- arrangeRect = rect . WithVerticalAlignment ( VerticalContentAlignment , row . Size . V ) ;
268+ var verticalAlignment = ( child as FrameworkElement ) ? . VerticalAlignment ?? VerticalAlignment . Top ;
269+ arrangeRect = rect . WithVerticalAlignment ( verticalAlignment , row . Size . V ) ;
305270 }
306271 else
307272 {
308- arrangeRect = rect . WithHorizontalAlignment ( HorizontalContentAlignment , row . Size . V ) ;
273+ var horizontalAlignment = ( child as FrameworkElement ) ? . HorizontalAlignment ?? HorizontalAlignment . Left ;
274+ arrangeRect = rect . WithHorizontalAlignment ( horizontalAlignment , row . Size . V ) ;
309275 }
310276
311277 var finalRect = arrangeRect . ToRect ( Orientation ) ;
0 commit comments