欢迎来到天天文库
浏览记录
ID:36383236
大小:92.59 KB
页数:9页
时间:2019-05-10
《WPF制作聊天窗口获取历史聊天记录》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、WPF制作聊天窗口获取历史聊天记录腾讯从QQ2013版起开始在聊天记录里添加了历史记录查看功能,个人聊天窗口可以点击最上边的‘查看历史消息’,而群组里的未读消息可以通过滚动鼠标中键或者拖动滚动条加载更多消息,那这个用wpf怎么实现呢?我用Scrollviewer和RichTextBox做了一个简陋尝试,真的是太陋了,大家戴好眼镜了哈。现在开始:首先是前台的陋XAML:2、xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="MainWindow"Height="350"Width="525"Loaded="Window_Loaded">3、ouseWheel="sv_richtextbox_PreviewMouseWheel"VerticalScrollBarVisibility="Auto"ScrollChanged="sv_richtextbox_ScrollChanged">4、iousadd"Content="前加"Height="30"Width="100"VerticalAlignment="Bottom"HorizontalAlignment="Left"Click="previousadd_Click">5、Height="30"Width="50"VerticalAlignment="Bottom"Margin="0,0,110,0"HorizontalAlignment="Right"Click="add20_Click">6、 在基本布局里添加了一个Scrollviewer包含RichTextBox,另外添加了4个Button控件来添加简单数据。previousadd往最上端插入数据,lastadd从底部添加数据。add20快速添加20条数据使之出现滚动条。 好了,下面是后台陋CS实现:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Windows;usingSystem.Windows.Controls;usingSystem.Wind7、ows.Data;usingSystem.Windows.Documents;usingSystem.Windows.Input;usingSystem.Windows.Media;usingSystem.Windows.Media.Imaging;usingSystem.Windows.Navigation;usingSystem.Windows.Shapes;namespacetestFlowDocument{//////MainWindow.xaml的交互逻辑///publicpartialclassM8、ainWindow:Window{publicMainWindow(){InitializeComponent();}inti=0;pr
2、xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="MainWindow"Height="350"Width="525"Loaded="Window_Loaded">3、ouseWheel="sv_richtextbox_PreviewMouseWheel"VerticalScrollBarVisibility="Auto"ScrollChanged="sv_richtextbox_ScrollChanged">4、iousadd"Content="前加"Height="30"Width="100"VerticalAlignment="Bottom"HorizontalAlignment="Left"Click="previousadd_Click">5、Height="30"Width="50"VerticalAlignment="Bottom"Margin="0,0,110,0"HorizontalAlignment="Right"Click="add20_Click">
3、ouseWheel="sv_richtextbox_PreviewMouseWheel"VerticalScrollBarVisibility="Auto"ScrollChanged="sv_richtextbox_ScrollChanged">4、iousadd"Content="前加"Height="30"Width="100"VerticalAlignment="Bottom"HorizontalAlignment="Left"Click="previousadd_Click">5、Height="30"Width="50"VerticalAlignment="Bottom"Margin="0,0,110,0"HorizontalAlignment="Right"Click="add20_Click">
4、iousadd"Content="前加"Height="30"Width="100"VerticalAlignment="Bottom"HorizontalAlignment="Left"Click="previousadd_Click">5、Height="30"Width="50"VerticalAlignment="Bottom"Margin="0,0,110,0"HorizontalAlignment="Right"Click="add20_Click">
5、Height="30"Width="50"VerticalAlignment="Bottom"Margin="0,0,110,0"HorizontalAlignment="Right"Click="add20_Click">
6、 在基本布局里添加了一个Scrollviewer包含RichTextBox,另外添加了4个Button控件来添加简单数据。previousadd往最上端插入数据,lastadd从底部添加数据。add20快速添加20条数据使之出现滚动条。 好了,下面是后台陋CS实现:usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Windows;usingSystem.Windows.Controls;usingSystem.Wind
7、ows.Data;usingSystem.Windows.Documents;usingSystem.Windows.Input;usingSystem.Windows.Media;usingSystem.Windows.Media.Imaging;usingSystem.Windows.Navigation;usingSystem.Windows.Shapes;namespacetestFlowDocument{//////MainWindow.xaml的交互逻辑///publicpartialclassM
8、ainWindow:Window{publicMainWindow(){InitializeComponent();}inti=0;pr
此文档下载收益归作者所有