Hi,
I can someone point me to any sample explaining, how to create XamDataGrid and add columns/rows and setting image in row cell and image in column header programmatically?
Thanks,
Sanjeev
Hi Sanjeev,You can easily add a new column using a UnboundField.(In the XamFeatureBrowser is an example how to add UnboundFields).http://help.infragistics.com/Help/NetAdvantage/WPF/2008.2/CLR3.X/html/xamDataGrid_Add_Unbound_Fields_to_xamDataGrid.html Creating FieldLayouts if this.xamDataGrid.FieldLayouts.Add(new FieldLayout()); Create the UnboundField: UnboundField imageField = new UnboundField(); imageField.Name = "InternelImage"; imageField.Label = bitmap; imageField.DataType = typeof(BitmapImage); Add the new Field to grid layouts: this.xamDataGrid.FieldLayouts[0].Fields.Add(imageField); You can add easily rows just using the: this.xamDataGrid.DataItems.Add(dData); where the dData should have structure as the Fileds in the XamDataGrid.Best Regards,DimiInfragistics Inc.
Hi Dimi,
Thanks for your help.
My other question is how to create Columns and rows programmatically. I need to create columns and rows programmatically and not binding directly to data source?
<igDP:XamDataGrid.FieldLayouts > <igDP:FieldLayout > <igDP:FieldLayout.Fields > <igDP:Field Name="From" Label ="From"> <igDP:Field.Settings > <igDP:FieldSettings AllowGroupBy ="False"/> </igDP:Field.Settings > </igDP:Field>
Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4
Hi Sanjeev,
The best way to set an image in a row cell is to set the style of the column to support image, and then just set the image as a value of the cell.
record.Cells["InternelImage"].Value = Picture;
In the XamFeatureBrowser is an example how to set image in a Field.
The best way to set an image in a column header is to change the default LabelPresenter style to support image. The default styles are located in …\DefaultStyles\DataPresenter\DataPresenterGeneric_Express.xaml. Changing the default style will allows you to use the default settings without overriding it.
And you can set the Field Label value to be the image.
this.xamDataGrid.FieldLayouts[0].Fields[0].Label = Picture;
Let me know if that would work in your scenario.
Dimi