Displaying Images in Datagrid in WPF C#
How to display images along with Data in a Datagrid in WPF
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Raaj KumarRank #7,836 · 233 reputationPosted Mar 7, 2010, 8:45 PM EST
Download latest WPFToolkitCheck and add reference to it. Then add few images to the project folder for displaying in datagrid. Now add the following XAML,
VerticalAlignment="Top"
ItemsSource="{Binding}"
AutoGenerateColumns="False">
and in code behind,
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
Loaded += new RoutedEventHandler(Window1_Loaded);
}
void Window1_Loaded(object sender, RoutedEventArgs e)
{
List
imageList.Add("Images/Sample1.jpg");
imageList.Add("Images/Sample2.jpg");
imageList.Add("Images/Sample3.jpg");
imageList.Add("Images/Sample4.jpg");
imageDataGrid.ItemsSource = imageList;
}
}
That's it.
Regards,
raaj