简体   繁体   English

控件以WPF显示消息

[英]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. 我想创建聊天程序,可以以不同的方式显示消息,尤其是在WP7下的IM +中。 But I in a fog, which control to choose. 但是我迷雾中,选择哪个控件。 Platform: .NET 4.0, WPF app. 平台:.NET 4.0,WPF应用。 PS: I found FlowDocumentScrollViewer some heavy, any other proposal? PS:我发现FlowDocumentScrollViewer有点沉重,还有其他建议吗? (Or good example how to use FlowDoc). (或很好的示例如何使用FlowDoc)。

I'd just go with a TextBlock for each message. 我只是为每个消息使用一个TextBlock。

A TextBlock can contain multiple different styles of text, so you could still support things like bold, italics, colors, hyperlinks, etc. TextBlock可以包含多种不同样式的文本,因此您仍然可以支持粗体,斜体,颜色,超链接等内容。

For beginners: WPF Flow Document For Beginners . 对于初学者: WPF初学者流文档

An advanced example from the same author: WCF / WPF Chat Application . 同一作者的一个高级示例: WCF / WPF聊天应用程序

The simplest Flow Document example: 最简单的Flow Document示例:

<!-- 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM