This is a migrated thread and some comments may be shown as answers.

BindingExpressionHelper goes boom

1 Answer 53 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Steve Evans
Top achievements
Rank 1
Steve Evans asked on 16 Jul 2010, 05:51 PM
Hi, 

I am getting an error when typing into the RadComboBox that states that it cant cast from type x to type y. The situation that we have is that the combo box is bound to a list of types that all implement a given interface but which do not necessarily share a common base type. The interface defines a property Description which is what we're actually binding to. If I use the combo box with the mouse and select from the list then all is fine, it is only when typing into the combo box that it blows up. Please see the attached stack trace for more info.

Thanks, Steve

1 Answer, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 19 Jul 2010, 02:45 PM
Hello Steve,

Unfortunately due to a performance optimization we introduced a couple of months ago, RadComboBox no longer supports items of different types. I understand that your scenario is completely valid and we will improve the control in that area, however, this will take some time. As a quick workaround I would suggest creating a new class, that wraps your items:

public class MyItem
{
    public IMyInterface Item { get; set; }
}

then bind RadComboBox to a collection containing MyItem objects. The telerik:TextSearch.TextPath will become Item.Description instead of Description as I suppose it was. Instead of changing TextPath, you could add an additional property in the wrapper class that exposes the interface property:
public string Decription
{
    get
    {
        return this.Item.Description;
    }
}

This is even better, because if you have lots of items (1000+ for example) you will be able to benefit from the aforementioned performance optimization, because it works only for simple properties.

I apologize for the inconvenience, your points have been updated.

Kind regards,
Valeri Hristov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
ComboBox
Asked by
Steve Evans
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Share this question
or