今天说下TabControl中遇到的坑 ,如题。废话不多说,先上代码:
private void creatNewTab(string head,string url) {
int index = getTabItemIndex(head);
if (index == -1) {
index = myTabControl.Items.Count;
Frame fm = new Frame();
fm.Source = new Uri(url,UriKind.Relative );
TabItem ti = new TabItem() { Header = head ,Content=fm};
myTabControl.Items.Add(ti);
}
myTabControl.SelectedIndex = index;
}
第一个坑坑:如何在WPF TabControl TabItem代码中动态插入Frame。
其实就是这么几句话。各位看官,简单吧?
据我多次测试,插入到TabItem的Frame 是