【发布时间】:2012-01-24 17:52:41
【问题描述】:
我想创建聊天程序,消息可以以不同的方式显示,尤其是WP7下的IM+。但我一头雾水,选择哪个控件。 平台:.NET 4.0,WPF 应用程序。 PS:我觉得 FlowDocumentScrollViewer 有点重,还有什么建议吗? (或如何使用 FlowDoc 的好例子)。
【问题讨论】:
标签: c# .net wpf wpf-controls
我想创建聊天程序,消息可以以不同的方式显示,尤其是WP7下的IM+。但我一头雾水,选择哪个控件。 平台:.NET 4.0,WPF 应用程序。 PS:我觉得 FlowDocumentScrollViewer 有点重,还有什么建议吗? (或如何使用 FlowDoc 的好例子)。
【问题讨论】:
标签: c# .net wpf wpf-controls
我会为每条消息使用一个 TextBlock。
一个 TextBlock 可以包含多种不同样式的文本,因此您仍然可以支持粗体、斜体、颜色、超链接等内容。
【讨论】:
初学者: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>
【讨论】: