user1167602
user1167602

Reputation: 3

Control to display messages in WPF

I wanna to create chat program, messages can be displayed in a different ways, especially like in IM+ under WP7. But I in a fog, which control to choose. Platform: .NET 4.0, WPF app. PS: I found FlowDocumentScrollViewer some heavy, any other proposal? (Or good example how to use FlowDoc).

Upvotes: 0

Views: 2138

Answers (2)

Peter Arandorenko
Peter Arandorenko

Reputation: 196

For beginners: WPF Flow Document For Beginners.

An advanced example from the same author: WCF / WPF Chat Application.

The simplest Flow Document example:

<!-- This simple flow document includes a paragraph with some
     bold text in it and a list. -->
<FlowDocumentReader xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <FlowDocument>
    <Paragraph>
      <Bold>Some bold text in the paragraph.</Bold>
      Some text that is not bold.
    </Paragraph>

    <List>
      <ListItem>
        <Paragraph>ListItem 1</Paragraph>
      </ListItem>
      <ListItem>
        <Paragraph>ListItem 2</Paragraph>
      </ListItem>
      <ListItem>
        <Paragraph>ListItem 3</Paragraph>
      </ListItem>
    </List>

  </FlowDocument>
</FlowDocumentReader>

Upvotes: 0

Joe White
Joe White

Reputation: 97708

I'd just go with a TextBlock for each message.

A TextBlock can contain multiple different styles of text, so you could still support things like bold, italics, colors, hyperlinks, etc.

Upvotes: 1

Related Questions