I have a Listview with CustomVisualItem formatting in IconView. When the directional keys are tapped or an item is clicked, the SelectItemChanged event is triggered but the selection highlight does not follow. Since CustomVisualItems are used, do I need to break out the crayons in VisualItemFormatting?
The form contains a RadListView and a RadLabel to display a result.
Thanks!public RadForm1()
{
InitializeComponent();
this.radListView1.EnableKineticScrolling = true;
this.radListView1.KeyboardSearchEnabled = true;
this.radListView1.ViewType = Telerik.WinControls.UI.ListViewType.IconsView;
this.radListView1.SelectedItemChanged += new System.EventHandler(this.radListView_SelectedItemChanged);
this.radListView1.VisualItemCreating += new Telerik.WinControls.UI.ListViewVisualItemCreatingEventHandler(this.radListView1_VisualItemCreating);
this.radListView1.DataSource = JunkData();
}
private void radListView1_VisualItemCreating(object sender, Telerik.WinControls.UI.ListViewVisualItemCreatingEventArgs e)
{
e.VisualItem = new CustomIconVisualItem();
}
private void radListView_SelectedItemChanged(object sender, EventArgs e)
{
RadListViewElement element = sender as RadListViewElement;
ListViewDataItem item = element.SelectedItem;
if (item == null) return;
DataRowView dataRow = (DataRowView)item.DataBoundItem;
if (dataRow == null) return;
DataRow row = dataRow.Row;
radLabel1.Text = row["Title"].ToString();
}
private DataTable JunkData()
{
DataTable dt = new DataTable();
dt.Columns.Add("Title", typeof(string));
dt.Rows.Add("T1");
dt.Rows.Add("T2");
dt.Rows.Add("T3");
return dt;
}
class CustomIconVisualItem : IconListViewVisualItem
{
private LightVisualElement titleElement;
private StackLayoutPanel stackLayout;
protected override void CreateChildElements()
{
base.CreateChildElements();
stackLayout = new StackLayoutPanel();
stackLayout.Orientation = System.Windows.Forms.Orientation.Vertical;
stackLayout.AutoSize = true;
titleElement = new LightVisualElement();
titleElement.NotifyParentOnMouseInput = true;
stackLayout.Children.Add(titleElement);
this.Children.Add(stackLayout);
}
protected override void SynchronizeProperties()
{
this.titleElement.Text = this.Data["Title"].ToString();
}
protected override Type ThemeEffectiveType
{
get
{
return typeof(SimpleListViewVisualItem);
}
}
}