I create an object type Message
than a list TableDataGrid_ItemSource = new ObservableCollection<Message>()
.
Before I had only DataGridTextColumn
columns and they were all binding the correct types of object Message.
<DataGridTextColumn Header="Type" Binding="{Binding MessageCategoryID.Type}" Width="*"/>
<DataGridTextColumn Header="Full text" Binding="{Binding FullTextMessage}" Width="*"/>
Now I want to customize a column by adding a text and an image both types of Message
object.
<DataGridTemplateColumn Header="Message ID">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Label Content="{Binding MessageID, Mode=OneWayToSource}" Width="*" Visibility="Visible"/>
<Image Source="{Binding Image}" HorizontalAlignment="Left" Width="20" Height="20"></Image>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
When I run I get this error:
An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.
Source="{Binding Image}"
is the problem! What is the DataType ofImage
? – Athafoud