WPF获取/复制TabItem的内容 [英] WPF Get/Copy content of a TabItem

查看:233
本文介绍了WPF获取/复制TabItem的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Heya,



我有一个使用TabHead / TabItem元素的WPF应用程序。我想在运行时创建新元素,内容与第一个元素相同(通常是包含更多元素的网格)。



Basicaly我希望函数看起来类似这样的事情:



Heya,

I have a WPF application that is using the TabHead/TabItem elements. I want to create new elements at runtime, with the same content as the first element (usually a grid with more elements).

Basicaly I would want the function to look something like this:

public TabItem TabItemAdd(TabControl CHead, TabItem Example, String Header="New Tab" )
{
TabItem item = new TabItem();
item.Content = Example.Content;  // <-- This line doesn't work and is the problem
item.Header = Header;
CHead.Items.Add(item);

return item;
}





现在我知道这不起作用,因为TabItem示例的元素已经全部是CHead的孩子了,但我不确定如何解开它们或让它工作



提前谢谢



Now I know that this doesn''t work because the elements of the TabItem Example are allready childrean of CHead, but I''m not exactly sure how to unbind them or get it to work

Thanks in advance

推荐答案

您可以获取标签项的克隆。然后尝试添加。它将是工作
you can get a clone for tab item . then try to add. it will be work


这篇关于WPF获取/复制TabItem的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆