【问题标题】:Control to display messages in WPF在 WPF 中显示消息的控件
【发布时间】:2012-01-24 17:52:41
【问题描述】:

我想创建聊天程序,消息可以以不同的方式显示,尤其是WP7下的IM+。但我一头雾水,选择哪个控件。 平台:.NET 4.0,WPF 应用程序。 PS:我觉得 FlowDocumentScrollViewer 有点重,还有什么建议吗? (或如何使用 FlowDoc 的好例子)。

【问题讨论】:

    标签: c# .net wpf wpf-controls


    【解决方案1】:

    我会为每条消息使用一个 TextBlock。

    一个 TextBlock 可以包含多种不同样式的文本,因此您仍然可以支持粗体、斜体、颜色、超链接等内容。

    【讨论】:

    • 谢谢,它使用 FlowDocument,所以它可以显示任何类型的控件来执行我的任务。我用过。
    【解决方案2】:

    初学者:WPF Flow Document For Beginners.

    来自同一作者的高级示例:WCF / WPF Chat Application

    最简单的流文档示例:

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

    【讨论】:

      猜你喜欢
      • 2011-01-16
      • 1970-01-01
      • 2011-03-22
      • 1970-01-01
      • 2014-01-16
      • 1970-01-01
      • 1970-01-01
      • 2011-01-27
      • 1970-01-01
      相关资源
      最近更新 更多