Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try making your own wrap panel deriving from standard wrap panel as described in <a href="http://social.msdn.microsoft.com/Forums/en/wpf/thread/b5791ef3-1bf5-477a-b7a4-fdadede3130f" rel="nofollow">this post</a> in detail. Post addresses the same issue which you are trying to solve.</p> <pre><code>public class MyWrapPanel : WrapPanel { public int MaxRows { get { return (int)GetValue(MaxRowsProperty); } set { SetValue(MaxRowsProperty, value); } } public static readonly DependencyProperty MaxRowsProperty = DependencyProperty.Register("MaxRows", typeof(int), typeof(MyWrapPanel), new UIPropertyMetadata(4)); protected override Size ArrangeOverride(Size finalSize) { Point currentPosition = new Point(); double ItemMaxHeight = 0.0; int RowIndex = 0; foreach (UIElement child in Children) { ItemMaxHeight = ItemMaxHeight &gt; child.DesiredSize.Height ? ItemMaxHeight : child.DesiredSize.Height; if (currentPosition.X + child.DesiredSize.Width &gt; this.DesiredSize.Width) { currentPosition = new Point(0, currentPosition.Y + ItemMaxHeight); ItemMaxHeight = 0.0; RowIndex++; } if (RowIndex &lt; MaxRows) { child.Visibility = System.Windows.Visibility.Visible; Rect childRect = new Rect(currentPosition, child.DesiredSize); child.Arrange(childRect); } else { Rect childRect = new Rect(currentPosition, new Size(0,0)); child.Arrange(childRect); } currentPosition.Offset(child.DesiredSize.Width, 0); } return finalSize; } protected override Size MeasureOverride(Size availableSize) { return base.MeasureOverride(availableSize); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload