BindingExpressionHelper goes boom

2 posts, 0 answers
  1. Steve Evans
    Steve Evans avatar
    23 posts
    Member since:
    May 2010

    Posted 16 Jul 2010 Link to this post

    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
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 19 Jul 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top