Hi,
I'm using a DataTable as the Datasource for a xamDataGrid. I have set the column captions for the columns directly on the datatable, but the grid is still using the column names as captions when it is displayed on screen. Is there a property / setting I'm missing that will make the grid use the captions instead of the names?
Thanks,Jacquers
Jacquers,
Technically, we think this is not an issue. The ITypedList that is implemented by the DataView returns PropertyDescriptors for the DataColumns, but they do not override the DisplayName and return the Caption of the column. We are considering finding a way around this so that the Captions are respected and override the Field's Label property.
Alex.
I am glad I helped. I am going to investigate this for you and follow up here in this thread.
Thanks, your sample code helped a lot!
Here is my code:
DataView dv = xamDataGrid1.DataSource as DataView; for (int i = 0; i < dv.Table.Columns.Count; i++) { xamDataGrid1.FieldLayouts[0].Fields[i].Label = dv.Table.Columns[i].Caption; }
Should I submit a bug report for the xamDatagrid not doing this correctly out of the box?
If you go with the FieldLayoutInitialized event, you can get the DataSource of the XamDataGrid as DataView and again make the label - caption adjustments.
DataView dv = xamDataGrid1.DataSource as DataView;
for (int i = 0; i < dv.Table.Columns.Count; i++)
{}
Well, I'm setting a datacontext in the code-behind and in the gui im using the following xaml:
<igDP:XamDataGrid DataSource="{Binding ContactData}" Margin="0,0,0,27" Name="xamDataGrid1" />
I'm using a MVVM pattern, so I dont have direct access to the datagrid from the viewmodel to use the .asEnumerable option. I assume the type of binding that I'm using is using the defaultview option.