Home > DeveloperSection > Forums > How to bind the local image in datagrid using wpf?
marcel ethan
marcel ethan

Total Post:105

Posted on    August-08-2013 7:43 AM


 1 Reply(s)
 5481  View(s)
Rate this:

I have a datagrid in wpf and I want to show an image in image column. How to do the task?

Please provide a demo if possible.

Any help will be appreciated.

shreesh chandra shukla
shreesh chandra shukla

Total Post:105

Posted on    August-09-2013 7:00 AM

You can use the below lines of code to show an image in image column of datagrid.
In window.xaml code :-
        <DataGrid AutoGenerateColumns="False" Margin="12" Name="dataGrid1">
                            <Image Source="{Binding ImageFilePath}" Width="50" Height="50" />
In window.xaml.cs code :-
public class imageBinding
            public BitmapImage ImageFilePath { get; set; }
        private void Window_Loaded(object sender, RoutedEventArgs e)
            for (int i = 0; i <= 20; i++)
                dataGrid1.Items.Add(new imageBinding { ImageFilePath = new BitmapImage(new Uri(@"Physical Image File Path           ")) });

Don't want to miss updates? Please click the below button!

Follow MindStick