Completed
Last Updated: 17 Sep 2014 08:46 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 15 Sep 2014 11:04
Category:
Type: Bug Report
0
FIX. RadDropDownList - NullReferenceException when scrolling with mouse wheel and at least one DescriptionTextListDataItem is added
To reproduce: 

1. Add a RadDropDownList and fill it with items at design time. Add at least one DescriptionTextListDataItem.
2. Click the arrow button to open the popup
3. Start scrolling with the mouse wheel. As a result a NullReferenceException is thrown.

Workaround:
public class CustomDropDownList : RadDropDownList
{ 
    public override string ThemeClassName  
    { 
        get 
        { 
            return typeof(RadListView).FullName;  
        }
    }

    protected override RadDropDownListElement CreateDropDownListElement()
    {
        return new CustomRadDropDownListElement();
    }
}

public class CustomRadDropDownListElement : RadDropDownListElement
{
    protected override Type ThemeEffectiveType     
    { 
        get    
        { 
            return typeof(RadDropDownListElement);     
        }
    }

    protected override void CreateChildElements()
    {
        base.CreateChildElements();
        this.UnwireEvents();
        this.ListElement = new CustomListElement();
        this.WireEvents();
    }
}

public class CustomListElement : RadListElement
{
    protected override VirtualizedStackContainer<RadListDataItem> CreateViewElement()
    {
        return new CustomContainer();
    }

    protected override Type ThemeEffectiveType     
    { 
        get    
        { 
            return typeof(RadListElement);     
        }
    }
}

public class CustomContainer : DefaultListControlStackContainer
{
    protected override int FindCompatibleElement(int position, RadListDataItem data)
    {
        if (data is DescriptionTextListDataItem)
        {
            for (int i = position + 1; i < this.Children.Count; i++)
            {
                DescriptionTextListVisualItem visualDescriptionItem = this.Children[i] as DescriptionTextListVisualItem;
                if (visualDescriptionItem != null && visualDescriptionItem.IsCompatible(data, null))
                {
                    return i;
                }
            }

            return -1;
        }
        return base.FindCompatibleElement(position, data);
    }
}
0 comments