Hi guys,
this issue seems to be reproduced again, when changed to IconListViewVisualItem and ListViewType.IconsView
I able to see unexpected spacing between items, which is randomly appear, when minimizing the container (form) to its minimal width.
attached are some screenshots of my problem and here is the reviewed code of the main form:
public
partial
class
Form1 : Form
{
private
BindingList<TraceMessage> _messages;
public
Form1()
{
InitializeComponent();
this
.radListView1.Dock = DockStyle.Fill;
radListView1.ViewType = ListViewType.IconsView;
//TODO: was ListViewType.ListView
this
.radListView1.AllowArbitraryItemHeight =
true
;
_messages =
new
BindingList<TraceMessage>();
for
(
int
i = 0; i < 10; i++)
{
_messages.Add(
new
TraceMessage()
{
MessageText = Guid.NewGuid().ToString() +
" "
+ Guid.NewGuid().ToString(),
Type = MessageTypes.Information,
TimeStamp = DateTime.Now.AddMinutes(i).ToShortTimeString()
});
}
radListView1.DataSource = _messages;
radListView1.DisplayMember =
"MessageText"
;
radListView1.SizeChanged +=
new
EventHandler(radListView1_SizeChanged);
radListView1.HorizontalScrollState = ScrollState.AlwaysHide;
radListView1.VisualItemCreating +=
new
ListViewVisualItemCreatingEventHandler(radListView1_VisualItemCreating);
}
void
radListView1_VisualItemCreating(
object
sender, ListViewVisualItemCreatingEventArgs e)
{
e.VisualItem =
new
TracerListElement();
}
protected
override
void
OnShown(EventArgs e)
{
base
.OnShown(e);
radListView1.ItemSize =
new
Size(
this
.radListView1.Width -
this
.radListView1.ListViewElement.ViewElement.VScrollBar.Size.Width, 0);
}
void
radListView1_SizeChanged(
object
sender, EventArgs e)
{
radListView1.ItemSize =
new
Size(
this
.radListView1.Width -
this
.radListView1.ListViewElement.ViewElement.VScrollBar.Size.Width, 0);
}
private
void
radListView1_VisualItemFormatting(
object
sender, Telerik.WinControls.UI.ListViewVisualItemEventArgs e)
{
e.VisualItem.TextWrap =
true
;
}
}
public
enum
MessageTypes { Warning, Error, Information }
public
class
TraceMessage
{
public
MessageTypes Type {
get
;
set
; }
public
string
MessageText {
get
;
set
; }
public
string
TimeStamp {
get
;
set
; }
}
class
TracerListElement : IconListViewVisualItem
//TODO: was SimpleListViewVisualItem
{
private
Color _warningColor = Color.Blue;
private
Color _errorColor = Color.Red;
private
Color _regularColor = Color.Black;
private
Color _timeStampColor = Color.Black;
private
readonly
Font _warningFont =
new
Font(
"Tahoma"
, 9, FontStyle.Bold, GraphicsUnit.Point);
private
readonly
Font _errorFont =
new
Font(
"Tahoma"
, 9, FontStyle.Bold, GraphicsUnit.Point);
private
readonly
Font _regularFont =
new
Font(
"Tahoma"
, 9, FontStyle.Bold, GraphicsUnit.Point);
private
LightVisualElement _timeStamp;
private
LightVisualElement _messageText;
private
WrapLayoutPanel _stackLayout;
public
TracerListElement()
{
BorderBoxStyle = BorderBoxStyle.FourBorders;
BorderBottomWidth = 1;
BorderLeftWidth = BorderRightWidth = BorderTopWidth = 0;
BorderColor = Color.Blue;
BorderGradientStyle = GradientStyles.Solid;
DrawBorder =
true
;
GradientStyle = GradientStyles.Solid;
}
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
_stackLayout =
new
WrapLayoutPanel { Orientation = Orientation.Horizontal };
_timeStamp =
new
LightVisualElement();
_timeStamp.TextAlignment = ContentAlignment.TopLeft;
_messageText =
new
LightVisualElement();
_messageText.TextWrap =
true
;
_messageText.TextAlignment = ContentAlignment.TopLeft;
_stackLayout.Children.Add(_timeStamp);
_stackLayout.Children.Add(_messageText);
Children.Add(_stackLayout);
}
protected
override
void
SynchronizeProperties()
{
var msg = (TraceMessage)Data.DataBoundItem;
_timeStamp.Text = msg.TimeStamp;
_timeStamp.ForeColor = _timeStampColor;
_stackLayout.AutoSize =
true
;
_stackLayout.AutoSizeMode = RadAutoSizeMode.Auto;
_messageText.AutoSize =
true
;
_messageText.AutoSizeMode = RadAutoSizeMode.Auto;
switch
(msg.Type)
{
case
MessageTypes.Information:
_messageText.ForeColor = _regularColor;
_messageText.Font = _regularFont;
break
;
case
MessageTypes.Warning:
_messageText.ForeColor = _warningColor;
_messageText.Font = _warningFont;
break
;
case
MessageTypes.Error:
_messageText.ForeColor = _errorColor;
_messageText.Font = _errorFont;
break
;
}
_messageText.Text = msg.MessageText;
_messageText.TextWrap =
true
;
}
protected
override
Type ThemeEffectiveType
{
get
{
return
typeof
(IconListViewVisualItem);
//TODO: was SimpleListViewVisualItem
}
}
}