I am a beginner to WPF .
I have a data grid for showing messages with column definitions as below . Data grid is bound to a datatable
<my:DataGridTextColumn Binding="{Binding Module}" Header="Module"
Width="75" IsReadOnly="True"></my:DataGridTextColumn>
<my:DataGridTextColumn Binding="{Binding Record ID}" Header="RecordID"
Width="75" IsReadOnly="True"></my:DataGridTextColumn>
<my:DataGridTextColumn Binding="{Binding ItemName}"
Header="Item/Platform/Country Name" Width="175" IsReadOnly="True">
</my:DataGridTextColumn>
<my:DataGridTextColumn Binding="{Binding DateReceived}"
Header="DateReceived" Width="150" IsReadOnly="True">
</my:DataGridTextColumn>
<my:DataGridTextColumn Binding="{Binding Comments}" Header="Comments"
Width="300" IsReadOnly="True"></my:DataGridTextColumn>
Now I need to add a coulmn with header as "Status" . and content as image . I am binding "IsRead" column of the datatable to this column such that if the IsRead value is False i need to show image unread.png and if the IsRead value is True i need to show image read.png
How do i do this?
You could create a StatusImage property in the class that holds your binding properties:
And then bind it to the image for example:
Or as in your case that you haven't got a class. You could choose between a datatrigger:
Or you could use a value converter:
Class:
Window Resources:
Then your binding would be:
Should all work.