GridView throws "Unable to cast object of type 'TypeA' to type 'TypeB'"

1 posts, 0 answers
  1. Anton
    Anton avatar
    3 posts
    Member since:
    Aug 2011

    Posted 13 Aug 2012 Link to this post

    Hi,
    I use GridView in following scenario:
    (meta code)

    Model:
    SomeCollection<TypeA>
    -SomeCollection<TypeB>

    XAML:
    <RadGridView ItemSource = {Binding SomeCollection<TypeA>}>
    <RowTemplate>
    <RadGridView ItemSource = {Binding SomeCollection<TypeB>}/> 
    </RowTemplate> 
    </RadGridView> 

    Problem:
    When first level GridView has grouping, during modifying the SomeCollection<TypeB> - exception will be thrown:
    System.InvalidCastException: Unable to cast object of type 'TypeA' to type 'TypeB'.
    Trace:
    at Telerik.Windows.Data.FuncExtensions+<>c__DisplayClass1`2[T,TResult].<ToUntypedFunc>b__0 (Object item) (IL offset: 0x0)
    at Telerik.Windows.Controls.GridView.GridViewDataControl.GenerateScrollingStack (Object dataItem) (IL offset: 0x66)
    at Telerik.Windows.Controls.GridView.GridViewDataControl+<>c__DisplayClass89.<ScrollIntoViewAsync>b__88 () (IL offset: 0x0)

    I have to say, this defect exists pretty long time, for 2-3 releases
Back to Top