Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
145
Problem Showing image in XamDataGrid
posted

Hello,

I have a xamDataGrid on my window, like this

<igDP:XamDataGrid Margin="2" Name="TechList" VerticalAlignment="Top" Background="{x:Null}" RecordActivated="TechList_RecordActivated" Theme="Office2k7Blue" GroupByAreaLocation="None" MinWidth="120" >
                    <igDP:XamDataGrid.FieldLayouts>
                        <igDP:FieldLayout>
                            <igDP:Field Name="TECHID" Width="Auto" Label="Tech ID" />
                            <igDP:Field Name="TECHNAME" Width="Auto" Label="Name" />
                        </igDP:FieldLayout>
                    </igDP:XamDataGrid.FieldLayouts>
                </igDP:XamDataGrid>

 

And in the code, I am adding a new column to the xamDataGrid as below:

                UnboundField imageField = new UnboundField();
                imageField.Name = "Special Truck";
                imageField.Label = "Special Truck";
                imageField.DataType = typeof(BitmapImage);
                this.TechList.FieldLayouts[0].Fields.Add(imageField);

 

I am defining the image as below:

                Image img = new Image();

                BitmapImage logo = new BitmapImage();
                logo.UriSource = new Uri("//Images/SpecialTruck.png",UriKind.Relative);
                img.Source = logo;

I have a datatable that I am generating in the code behind and assigning it to the XamDataGrid.

Before I assign it to the XamDataGrid, I am adding a image column to the datatable as below

DataTable.Columns.Add("Special Truck",typeof(Image));

then I fill the datable with the above defined image. I see the datatable contains the image, but when I assign XamDataGrid.DataSource = DataTable.DefualtView();

all other contents are displaying except the Image.