Hi,
I am having trouble binding a class with 2 members to a RadGridView. The first member contains a dictionary to set the column header text and the second to fill the grid.
here is my sample project
cs
xaml
When I set Listing.DataContext = ContextSource, it will only fill the header text property. The grid is not populated.
If I direct the Listing.DataContent directly to ContextSource.DataSrc then the grid is populated, but the headers are not set.
Any idea what I am doing wrong?
Kind regards,
Dennis
I am having trouble binding a class with 2 members to a RadGridView. The first member contains a dictionary to set the column header text and the second to fill the grid.
here is my sample project
cs
public
Content()
{
// Get the labels from database
ContextSource.Labels = DictionaryFromDatabase();
// Get grid data from database
ContextSource.DataSrc = DataTableFromDatabase();
Listing.DataContext = ContextSource;
}
public
class
ContextSource
{
public
DataTable DataSrc {
get
;
set
; }
public
Dictionary<
string
,
string
> Labels {
get
;
set
; }
public
ContextSource()
{
DataSrc =
new
DataTable();
Labels =
new
Dictionary<
string
,
string
>;
}
}
xaml
<
telerik:RadGridView
Margin
=
"0"
AreRowDetailsFrozen
=
"True"
AutoGenerateColumns
=
"False"
CanUserFreezeColumns
=
"False"
IsReadOnly
=
"True"
ItemsSource
=
"{Binding}"
SelectionMode
=
"Single"
ShowInsertRow
=
"False"
x:Name
=
"Listing"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
Header
=
"{Binding Labels.[str_label0]}"
DataMemberBinding
=
"{Binding Path=DataSrc.[columnname0]}"
/>
<
telerik:GridViewDataColumn
Header
=
"{Binding Labels.[str_label1]}"
DataMemberBinding
=
"{Binding Path=DataSrc.[columnname1]}"
/>
<
telerik:GridViewDataColumn
Header
=
"{Binding Labels.[str_label2]}"
DataMemberBinding
=
"{Binding Path=DataSrc.[columnname2]}"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
When I set Listing.DataContext = ContextSource, it will only fill the header text property. The grid is not populated.
If I direct the Listing.DataContent directly to ContextSource.DataSrc then the grid is populated, but the headers are not set.
Listing.DataContext = ContextSource.DataSrc;
Any idea what I am doing wrong?
Kind regards,
Dennis