MVVM WPF数据绑定到类似Skype的聊天? [英] MVVM WPF databinding to a Skype-like chat?
问题描述
你们都知道并喜欢Skype聊天界面:每个消息都封装在泡沫中,表情符号和链接功能,以及左侧的头像。
如果我正在创建一个类似Skype的界面,那么每个邮件的最理想的WPF组件是什么?
我正在使用MVVM,所以我的所有消息都作为ObservableCollection存储在ViewModel中。
我有有问题绑定到RichTextBox,所以我已经调查绑定到列表框,其中每个列表项是一个消息,每个项目被风格为具有Skypey边框和头像等。
任何想法?
我发现唯一合适的解决方案是使用flowdocumentreader和ivalueconverter来转换数组的字符串到一个流文件。一旦我制作了类似于bbcode的脚本语言,它实际上会很好用。
这是我从中学到的示例。 http://michaelsync.net/2009/ 06/09 / bindable-wpf-richtext-editor-with-xamlhtml-convertor
对我来说有点过分,所以我最终只是做ivalueconverter和简单的脚本语言。
Hey guys, I've got what I think is an interesting question:
You all know and love the Skype chat interface: each message is enclosed in a bubble, with emoticons and link capabilities, as well as an avatar at the left.
What is the most ideal WPF component to house each message in, if I were creating a Skype-like interface?
I am using MVVM, so all my messages are stored in the ViewModel as an ObservableCollection.
I have had problems binding to a RichTextBox, and so I have investigated binding to a Listbox, where each list item is a message and each item is styled to have a Skypey border and avatar etc.
Any ideas?
The only suitable solution that I have found is using the flowdocumentreader and an ivalueconverter to convert an array of strings to a flowdocument. It actually works great once I made my own scripting language similar to bbcode.
This was the sample I learned from. http://michaelsync.net/2009/06/09/bindable-wpf-richtext-editor-with-xamlhtml-convertor
It was a little overkill for me so I ended up just making the ivalueconverter and a simple script language.
这篇关于MVVM WPF数据绑定到类似Skype的聊天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!