Completed
Last Updated: 31 Mar 2014 10:14 by ADMIN
ADMIN
Georgi I. Georgiev
Created on: 16 Dec 2013 08:33
Category:
Type: Bug Report
1
FIX. RadListView - NullReferenceException when dragging items with some of the themes
To reproduce:
Add a RadListView with some items. The issue appears sporadically and there are no exact steps to reproduce known, it appears to be very environment specific. You simply need to change the theme and drag an item. Themes which have been reported:
Aqua
Office2007Black
Office2007Silver
Office2010Blue
VisualStudio2012Dark
VisualStudi2012Light
Windows7
Windows8

Workaround:
Use the following custom RadListView:
public class MyListView : RadListView
{
protected override RadListViewElement CreateListViewElement()
{
return new MyListViewElement();
}
}

public class MyListViewElement : RadListViewElement
{
protected override BaseListViewElement CreateViewElement()
{
if (this.ViewType == ListViewType.IconsView)
{
return new MyIconsListViewElement(this); 
}

return base.CreateViewElement();
}
}

public class MyIconsListViewElement : IconListViewElement
{
public MyIconsListViewElement(RadListViewElement owner)
: base(owner)
{
}

public override Point GetDragHintLocation(BaseListViewVisualItem visualItem, Point mouseLocation)
{
if (this.DragHint == null)
{
return Point.Empty;
}

Rectangle itemBounds = visualItem.ElementTree.Control.RectangleToScreen(visualItem.ControlBoundingRectangle);
Padding margins = Padding.Empty;
int imageHeight = 1;

RadImageShape imageShape = this.DragHint;
if (imageShape != null)
{
imageHeight = imageShape.Image.Size.Height;
margins = imageShape.Margins;
}
else
{
return Point.Empty;
}

bool isDropAtTop = mouseLocation.Y <= visualItem.Size.Height / 2;

int y = isDropAtTop ? itemBounds.Y : itemBounds.Bottom;
return new Point(itemBounds.X - margins.Left, y - imageHeight / 2);
}
}
0 comments