Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Xamgrid and heterogeneous collections

I have the following class hierarchy (pseudocode):


DerivedClass1 : BaseClass

DerivedClass2 : BaseClass

I have a heterogeneous collection of BaseClass items that contains DerivedClass1 and DerivedClass2 items. When I bind this collection to a xamgrid and specify columns in xamgrid columns as following:

x:Name="XamGrid_Mygrid" d:DataContext="{d:DesignInstance viewModel:BaseClassListViewModel,IsDesignTimeCreatable=False}"
ItemsSource="{Binding PagedCollection}"
<ig:TextColumn IsFixable="True" x:Name="Base Clas" Key="BaseClass" HeaderText="Base Class" />
<ig:TextColumn IsFixable="True" x:Name="Derived Clas" Key="DerivedClass" HeaderText="Derived Class" />
<ig:PagerSettings AllowPaging="Bottom" />

I get runtime error saying that the Column called DerivedClass (which is present in DerivedClass1) is not found. What is a way around it?


  • 138253
    Verified Answer
    Offline posted

    Hello Andrew,


    Thank you for your post. I have been looking into it and I can say that the XamGrid is not designed to show heterogeneous data by default. The thing you can do is using UnboudColumns, because their keys don’t have to be names of a properties from the data source. I have created a sample project to show you this approach. I used a similar data structure to the one you described. Please let me know if this helps you or you have further questions on this matter.


    Looking forward for your reply.
Reply Children
No Data