我需要在DataGrid中顯示的圖像,但它顯示像下面Datagrid的不具約束力的圖像
System.windows.controls.Image System.windows.controls.Image
我是數據表添加類型爲Image的列,並且通過讀取字節[]並轉換爲圖像然後分配給數據表來控制該行。
//Creating the column type
if (header.ColumnDescription == "ActiveStatus")
{
dc = new DataColumn(header.ColumnDescription, typeof(Image));
dt.Columns.Add(dc);
}
//Filling the data column
foreach (DataColumn col in dt.Columns)
{
dr[col] = GetRowItem(device, col.Caption);
}
dt.Rows.Add(dr);
//Logic for getting the image
Image img=new Image();
BitmapImage logo = new BitmapImage();
logo.BeginInit();
logo.UriSource = new Uri("pack://application:,,,/Resources/Images/cloud_logon_radio_btn_green.png");
logo.EndInit();
img.Source = logo
什麼問題?