To reproduce:
Add a RadListView set its settings as follows:
this.radListView1.ViewType = Telerik.WinControls.UI.ListViewType.IconsView;
this.radListView1.ListViewElement.ViewElement.Orientation = Orientation.Horizontal;
this.radListView1.ItemSize = new Size(200, 200);
Add items:
this.radListView1.Items.Add("Item");
this.radListView1.Items.Add("Item");
this.radListView1.Items.Add("Item");
Lower the height of the form until its lower than the height of the items. You will notice that the items are moved to the right
Workaround:
public class ListView : RadListView
{
protected override RadListViewElement CreateListViewElement()
{
return new ListViewElement();
}
}
public class ListViewElement : RadListViewElement
{
protected override BaseListViewElement CreateViewElement()
{
if (this.ViewType == ListViewType.IconsView)
{
return new IconsViewElement(this);
}
return base.CreateViewElement();
}
protected override Type ThemeEffectiveType
{
get
{
return typeof(RadListViewElement);
}
}
}
public class IconsViewElement : IconListViewElement
{
public IconsViewElement(RadListViewElement owner)
: base(owner)
{
}
protected override VirtualizedStackContainer<ListViewDataItem> CreateViewElement()
{
return new IconsListViewContainer(this);
}
}
public class IconsListViewContainer : IconListViewContainer
{
private Rectangle clientRect;
public IconsListViewContainer(BaseListViewElement owner) : base(owner)
{
}
private bool Grouped
{
get
{
return this.owner.Owner.ShowGroups && (this.owner.Owner.EnableCustomGrouping || this.owner.Owner.EnableGrouping);
}
}
protected override SizeF ArrangeUngroupedHorizontal(SizeF finalSize)
{
if (this.clientRect == null)
{
clientRect = (Rectangle)
this.GetType().BaseType.GetField("clientRect", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)
.GetValue(this);
}
float x = clientRect.X + this.ScrollOffset.Width, y = clientRect.Y;
float maxHeight = 0;
float maxWidth = 0;
foreach (RadElement element in this.Children)
{
BaseListViewVisualItem visualItem = element as BaseListViewVisualItem;
if (visualItem == null || visualItem.Data == null)
continue;
Size elementSize = this.ElementProvider.GetElementSize(visualItem.Data).ToSize();
maxHeight = Math.Max(maxHeight, elementSize.Height);
maxWidth = Math.Max(maxWidth, elementSize.Width);
if (y + elementSize.Height > clientRect.Bottom && y != clientRect.Y)
{
y = clientRect.Y;
x += maxWidth + this.ItemSpacing;
maxWidth = elementSize.Width;
}
if (x == clientRect.X &&
this.Grouped &&
(this.owner.Owner.Groups.Count > 0) &&
!this.owner.Owner.FullRowSelect)
{
x += this.owner.Owner.GroupIndent;
}
RectangleF arrangeRect = new RectangleF(new PointF(x, y), elementSize);
if (this.RightToLeft)
{
arrangeRect = LayoutUtils.RTLTranslateNonRelative(arrangeRect, clientRect);
}
element.Arrange(arrangeRect);
y += elementSize.Height + this.ItemSpacing;
}
return finalSize;
}
}