But when I binding an iList contain Inheritance class,the grid only show Inheritance class field/property,the base class field/property do not show.
4 Answers, 1 is accepted
RadGridView tries to infer the type of items in the collection it is bound to. The moment it sees an IList<Something> it deduces that Something is the item type, not checking if you actually have InheritedSomething objects inside.
This one is easy to fix -- turn your collection into a typed collection of the inherited type. LINQ makes that dead easy -- if you have an IList<Message>, you can transform it to an IEnumerable<InheritedMessage> using the Cast() extension method:
//will be treated as a collection of Message objects not including properties from InheritedMessage |
//RadGridView1.ItemsSource = GetMessages(); |
//will be treated as a collection of InheritedMessage objects |
RadGridView1.ItemsSource = GetMessages().Cast<InheritedMessage>(); |
I am attaching a sample project for your reference.
All the best,
Hristo Deshev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.

I found that not even having collections of inherited type will help with properties defined on base class.
Here is example:
Create C# Silverlight project RadGridInheritance
Add references to:
Telerik.Windows.Controls
Telerik.Windows.Controls.GridView
Telerik.Windows.Controls.Navigation
Add ContactSettings.cs:
using System;
using System.Collections.ObjectModel;
namespace RadGridInheritance
{
public class ContactType
{
public string Description { get; set; }
}
public class AddressType:ContactType
{
public bool IsPostal { get; set; }
}
public class PhoneType
{
public string Description { get; set; }
}
public class ContactSettings
{
public ObservableCollection<ContactType> ContactTypes { get; set; }
public ObservableCollection<AddressType> AddressTypes { get; set; }
public ObservableCollection<PhoneType> PhoneTypes { get; set; }
}
}
And page.xaml:
<UserControl x:Class="RadGridInheritance.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
xmlns:telerik2="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
Width="400" Height="350">
<Grid x:Name="LayoutRoot" Background="White">
<Grid.RowDefinitions>
<RowDefinition />
</Grid.RowDefinitions>
<telerikNavigation:RadTabControl Grid.Row="1">
<telerikNavigation:RadTabControl.ItemsPanel>
<ItemsPanelTemplate>
<telerik2:RadWrapPanel />
</ItemsPanelTemplate>
</telerikNavigation:RadTabControl.ItemsPanel>
<telerikNavigation:RadTabItem Header="Address Types">
<ScrollViewer VerticalScrollBarVisibility="Auto" BorderThickness="0">
<Grid>
<telerik:RadGridView
x:Name="AddressTypeGrid"
ItemsSource="{Binding AddressTypes}"
AutoGenerateColumns="False"
IsReadOnly="True"
Height="300"
ColumnsWidthMode="Auto"
ShowGroupPanel="False" >
<telerik:RadGridView.Columns>
<telerikGridView:GridViewDataColumn HeaderText="Description" UniqueName="Description" />
<telerikGridView:GridViewDataColumn HeaderText="IsPostal" UniqueName="IsPostal" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
</ScrollViewer>
</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="Contact Types">
<ScrollViewer VerticalScrollBarVisibility="Auto" BorderThickness="0">
<Grid>
<telerik:RadGridView
x:Name="ContactTypeGrid"
ItemsSource="{Binding AddressTypes}"
AutoGenerateColumns="False"
Height="300"
IsReadOnly="True"
ColumnsWidthMode="Auto"
ShowGroupPanel="False" >
<telerik:RadGridView.Columns>
<telerikGridView:GridViewDataColumn HeaderText="Description" UniqueName="Description" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
</ScrollViewer>
</telerikNavigation:RadTabItem>
<telerikNavigation:RadTabItem Header="Phone Types">
<ScrollViewer VerticalScrollBarVisibility="Auto" BorderThickness="0">
<Grid>
<telerik:RadGridView
x:Name="PhoneTypeGrid"
ItemsSource="{Binding PhoneTypes}"
AutoGenerateColumns="False"
Height="300"
IsReadOnly="True"
ColumnsWidthMode="Auto"
ShowGroupPanel="False" >
<telerik:RadGridView.Columns>
<telerikGridView:GridViewDataColumn HeaderText="Description" UniqueName="Description" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
</ScrollViewer>
</telerikNavigation:RadTabItem>
</telerikNavigation:RadTabControl>
</Grid>
</UserControl>
When you run the project you will notice that Description column on first 2 tabs displays no information.

example you have posted is WPF. When I run that code in Silverlight I get only Headers column.
As far as I can see issue is that grid can't be bound to properties defined in the base class as Thomas mentioned. This also affects column autogenaration.
I've reproduced the bug. It appears on Silverlight only, and we will fix it for our next release. Thanks for reporting that! I have updated your Telerik points.
Best wishes,
Hristo Deshev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.