使用 Richtextbox 作为聊天窗口,显示 WPF 中存在文本自定义问题的文本 [英] Using richtextbox as a chat window which displays text having text customization issues in WPF

查看:35
本文介绍了使用 Richtextbox 作为聊天窗口,显示 WPF 中存在文本自定义问题的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个 C# WPF 聊天信使,我使用了 Wpf 富文本框来显示聊天,但我正在尝试自定义 nick 并进行一些文本对齐,具有文本的富文本框是通过使用代码附加文本来制作的,我不知道如何自定义它,我附上一张图片以获得更多解释

I am making a C# WPF chat messenger, i have used Wpf rich text box for displaying chat, but i am trying to customize nick and do some text alignment, rich text box having text is made by appending text using code, i dont know how to customize it, i am attaching an image for more explanation

我希望这个日期左对齐,并且我希望昵称应该是蓝色的.我想我们不能在富文本框中使用HTML文本,或者自定义文本的解决方案是什么,我应该使用一些标签,还是什么,请告诉我更好的解决方案.

I want this date to be left aligned, and i want the nick name should be blue in color. I think we cannot use HTML Text in rich text box, or whats the solution for customizing the text, should i use some tags, or what, please let me know the better solution.

推荐答案

使用 FlowDocument 并在发送/接收每条消息时附加到文档的内容可能会更好地为您服务 (点击了解更多信息).

You may be better served by using a FlowDocument and appending to the document's content as each message is sent/received (click for more info).

这篇关于使用 Richtextbox 作为聊天窗口,显示 WPF 中存在文本自定义问题的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆