Completed
Last Updated: 25 Aug 2020 10:21 by ADMIN
Release R3 2020 (LIB 2020.2.826)
Stoyan
Created on: 21 Aug 2020 12:24
Category: DropDownList
Type: Bug Report
0
RadDropDownList: The SvgImage property is not available for the data items

One cannot set the SvgImage of the RadListDataItems.

Additionally, when ShowImageInEditorArea is true the SvgImage must be displayed in the editor area.

1 comment
ADMIN
Todor
Posted on: 21 Aug 2020 13:03

As a workaround I can suggest storing the RadSvgImage in the Tag property of the RadListDataItems:

for (int i = 1; i <= 3; i++)
{
    RadListDataItem item = new RadListDataItem(i.ToString());
    item.Tag = RadSvgImage.FromFile("1.svg");
    this.radDropDownList1.Items.Add(item);
}
Then to display the SvgImages in the visual items of the pop-up you can use the VisualItemFormatting event:
private void radDropDownList1_VisualListItemFormatting(object sender, VisualItemFormattingEventArgs args)
{
    args.VisualItem.SvgImage = (RadSvgImage)args.VisualItem.Data.Tag;
}
And to synchronize the editor area SvgImage with the selected item when ShowImageInEditorArea is true you can use the SelectedIndexChanged event:
private void RadDropDownList1_SelectedIndexChanged(object sender, Telerik.WinControls.UI.Data.PositionChangedEventArgs e)
{
    if (this.radDropDownList1.SelectedItem != null)
    {
        this.radDropDownList1.DropDownListElement.EditableElement.SvgImage = (RadSvgImage)this.radDropDownList1.SelectedItem.Tag;
    }
    else
    {
        this.radDropDownList1.DropDownListElement.EditableElement.SvgImage = null;
    }
}