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();html 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、⽰例下载:
QAF
开发思路清晰,如果需要项⽬源码,可以加我号,发送天机朋友申请【⾼仿IM】
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论