Since you are having a list of strings containing the path of the Images, you have to use a Converter class to convert the string to BitmapImage.
namespace WpfApplication1
{
class ConvertTextToImage:IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if(value!=null)
{
return new BitmapImage(new Uri(value.ToString(), UriKind.RelativeOrAbsolute));
}
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
}
Use the XAML as follows (removed the ItemsSource from the XAML)
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
Title="Window1" Height="334" Width="686" xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit" Loaded="Window_Loaded">
<window.resources>
<local:converttexttoimage x:key="convert" xmlns:x="#unknown" xmlns:local="#unknown" />
</window.resources>
<Grid>
<my:DataGrid AutoGenerateColumns="False" Margin="144,60,141,0" Name="dataGrid1" VerticalAlignment="Top"
Height="40">
<my:DataGrid.Columns>
<my:DataGridTemplateColumn Header="Icon">
<my:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Image Height="25" Width="50" Source="{Binding Converter={StaticResource convert}}" />
</DataTemplate>
</my:DataGridTemplateColumn.CellTemplate>
</my:DataGridTemplateColumn>
<my:DataGridTextColumn Header="Game Name" Binding="{Binding Path=Position}"/>
</my:DataGrid.Columns>
</my:DataGrid>
</Grid>
</Window
Should work now.