I want to retrieve data(they are all image parameters) from csv file and display them in the datagrid. Alongside, each entry I want to display thumbnail of an image. How do I go about having both image and other entries in the datagrid ? So, here I have
Entity
public class ImageProperties
{
public string ImageThumbNailPath{ get; set;}
public string ImageFileName{ get; set;}
public double Sharpness{ get; set;}
public int ImageWidth{ get; set;}
public int ImageHt{ get; set;}
...
}
Xaml
<DataGrid x:Name="dataGridView" ItemsSource="{Binding ImagePropertiesList}" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTemplateColumn Header="Image">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Height="25" Width="50" Source="{Binding ImageThumbNailPath}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
From ViewModel:
var ImagePropertiesList = new ObservableCollection<ImageProperties>();
ImagePropertiesList.Add(new ImageProperties() {
ImageThumbNailPath=@"C:\Users\imgIcon.tif", ImageFileName="imgIcon.tif",
Sharpness = 4.5, ImageWidth=50, ImageHt = 50 });
With above, I'm neither able to see the image nor the text data...I see I'm not enabling a way to display the texts but not sure how I should do that when combining with image.
My ImageProperties class might get modified to include more properties hence i don't want to include something like below for each property.
<DataGridTextColumn Header="ImageWidth" Binding="{Binding ImageWidth}"/>
Is there a way I could still show the image in the first column and all other properties in subsequent columns ? Please, guide me.