Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

How would I achieve this style of display for messages?

$
0
0

Hello. Basically I'm after a specific kind of message format for my chat application. I want it to be selectable so that users are able to copy chat text. Below is an image on what the desired result will be.

I have managed to create similar styles using a Grid inside a FlowDocument however it wasn't selectable. I have also created a similar result using Tables, however the downfall to this is that column widths don't match the contents full width unlike grids. Below is my attempt with tables none the less. 

<FlowDocumentScrollViewer Grid.Row="0" BorderBrush="Silver" BorderThickness="0,0,0,1"><FlowDocument FontSize="12"><Table><Table.Columns><TableColumn Width="30*" /><TableColumn Width="auto" /></Table.Columns><TableRowGroup><TableRow><TableCell><Paragraph>[time] User:</Paragraph></TableCell><TableCell><Paragraph>I am a long message ok.</Paragraph></TableCell></TableRow></TableRowGroup></Table></FlowDocument></FlowDocumentScrollViewer>

For multiple messages, as would be the same with Grids, it would be a separate table per message. Of course with the table I end up with large spaces on the end of usernames as the width isn't really that automatic.

Any idea how I can achieve the desired result as shown in the image? Thanks in advance.


Viewing all articles
Browse latest Browse all 18858

Trending Articles