WPF开发微信三、高仿微信对话框
1、效果图

2、示例目标
根据选择的对话,创建Frame Page页面,如果已经存在则之间显示;
3、C# 代码
Dictionary<String, Frame> dic = new Dictionary<string, Frame>();
private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (listBox.SelectedItem != null)
{
ListBoxItem item = (ListBoxItem)listBox.SelectedItem;
String Key = item.Name;
if (!dic.ContainsKey(Key))
{
Frame frame = new Frame();
frame.Visibility = Visibility.Collapsed;
int tag = Convert.ToInt32(item.Tag);
if (tag == 1)
{
PageFriendTalk pageA = new PageFriendTalk(new PageData() { key = Key });
frame.Navigate(pageA, new object() { });
}
if(tag == 2)
{
PageGroupTalk pageA = new PageGroupTalk(new PageData() { key = Key });
frame.Navigate(pageA, new object() { });
}
gridTalk.Children.Add(frame);
dic.Add(Key, frame);
}
foreach (KeyValuePair<string, Frame> kvp in dic)
{
if(kvp.Key.Equals(Key))
kvp.Value.Visibility = Visibility.Visible;
else
kvp.Value.Visibility = Visibility.Collapsed;
}
}
}
4、示例下载:WpfImTalk1.0.zip
QAF
开发思路清晰,如果需要项目源码,可以加我号,发送天机朋友申请【高仿微信IM】


浙公网安备 33010602011771号