I have an issue similar to this post:
http://www.telerik.com/community/forums/silverlight/gridview/binding-itemssource-to-observablecollection-lt-baseclass-gt-causes-exception.aspx
Basically, I have base class, and 3 classes the inherit from the base class. I bind the grid to a collection of items that is a mix of the inherited classes. The grid is set up to only displays properties from the base class, however after binding, the columns do not display any data. (and grouping by a column of the base class throws an error.
Below is a simplified version of what I am trying to do. Is there anything I can do to get it to work? I'm using version 2011.1.620.1040.
Thanks.
http://www.telerik.com/community/forums/silverlight/gridview/binding-itemssource-to-observablecollection-lt-baseclass-gt-causes-exception.aspx
Basically, I have base class, and 3 classes the inherit from the base class. I bind the grid to a collection of items that is a mix of the inherited classes. The grid is set up to only displays properties from the base class, however after binding, the columns do not display any data. (and grouping by a column of the base class throws an error.
Below is a simplified version of what I am trying to do. Is there anything I can do to get it to work? I'm using version 2011.1.620.1040.
Thanks.
public
class
BaseClass
{
public
string
Name {
get
;
protected
set
; }
}
public
class
InheritedClass1 : BaseClass
{
public
InheritedClass1()
{
this
.Name =
"Class 1"
;
}
}
public
class
InheritedClass2 : BaseClass
{
public
InheritedClass2()
{
this
.Name =
"Class 2"
;
}
}
void
MainPage_Loaded(
object
sender, RoutedEventArgs e)
{
List<BaseClass> list =
new
List<BaseClass>();
list.Add(
new
InheritedClass1());
list.Add(
new
InheritedClass1());
list.Add(
new
InheritedClass2());
list.Add(
new
InheritedClass2());
gridView1.ItemsSource = list;
}
<
telerik:RadGridView
Name
=
"gridView1"
AutoGenerateColumns
=
"False"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
DataMemberBinding
=
"{Binding Name}"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>