InvalidCastException when filtering

3 posts, 0 answers
  1. Joe
    Joe avatar
    48 posts
    Member since:
    Dec 2007

    Posted 10 Apr 2013 Link to this post

    I am getting an InvalidCastException when there are 2 different classes at the same level of the tree hierarchy. For example, I have an MvDirectory class and an MvFile class. They both implement an int property called Size. They also share a common interface that implements Size. If I have a level of the hierarchy that consists of only MvDirectory instances, the filtering works fine. As soon as I add an instance of MvFile to the same level, I get an exception saying that MvFile cannot be cast to MvDirectory. I'm not sure why it is assuming all nodes at the same level are of the same type. Is there some way of getting it to use the shared interface or am I going to have to populate my tree with instances of the same class? Or am I just missing something?

    Thanks,
    Joe
  2. Yordanka
    Admin
    Yordanka avatar
    634 posts

    Posted 11 Apr 2013 Link to this post

    Hello Joe,

    Generally, this scenario is not supported and we cannot do much. We suggest you to move all logic to the base class and to work with it.
     
    Kind regards,
    Yordanka
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Joe
    Joe avatar
    48 posts
    Member since:
    Dec 2007

    Posted 11 Apr 2013 Link to this post

    Ok, thanks. The classes share an interface but not a common base class. I'll probably put them in some kind of wrapper, then.
Back to Top