I currently have a xamDataGrid that displays rows related to messaging (text/email) between 2 people, basically a conversation history. Currently I also display a column that shows an image if the message had an attachment. For instance if a Word doc was attached to the message then the user would see a Word icon in the column indicating that a doc was sent with them essage, they can click the icon and view the doc that was sent. The limitation right now is that the sytem will only allow 1 attached per message, the attachment is stored in the tMessageTransaction table as a binary and a related column that srtoed the file extension. The file extension is used in the converter template to know which icon to display based on the file type. All this works great.
Now I want to move the storage of the attachments to a details table so that a message can have multiple attachments. What I'm looking for help with is how to modify the xamDataGrid to account for this.
Here's the current xaml snippet related to the Attachment column,
<igDP:Field Name="FileExtension" Label=""><igDP:Field.Settings>
<igDP:FieldSettings>
<igDP:FieldSettings.CellValuePresenterStyle>
<Style TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Image ToolTip="View attachment" Cursor="Hand" Width="23" PreviewMouseLeftButtonDown="Image_PreviewMouseLeftButtonDown" IsEnabled="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:CellValuePresenter}},Path=Value}"Source="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:CellValuePresenter}},Path=Value,Converter={StaticResource converter}}">
</Image>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</igDP:FieldSettings.CellValuePresenterStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
The data is loaded based on a dataset, so this would also have to be modified to include the detail rows from the new table of multiple attachments.
I'm not sure how to go about doing this and would appreciate any guidance someone can offer.
Thanks
Troy
Hello Troy,
Thank you for your post. I have been looking into it and I can suggest you use a ListBox instead of an Image as ContentTemplate of the CellValuePresenter and you can create an ItemTemplate with an Image. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Hi Stefan,
Thanks for the reply. I'm not quote sure how to implement that idea using a ListBox and itemTemplate. Would you happen to have abit of sample code?
I created a sample project for you, which shows how to display a collection in a single column. I used ListView and put a TextBlock in its ItemTemplate, but you can feel free to modify the CellValuePresenter as per your requirements.Please let me know if this helps you or you need further assistance on this matter.