如何在运行时将内容插入Tabitems [英] How to insert content into tabitems at runtime

查看:120
本文介绍了如何在运行时将内容插入Tabitems的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Heya,

我在应用程序中添加了一个带有一个(单个)Tabitem且内部带有文本框的Tabcontrol.现在,如果我要使用以下内容创建一个新标签:

CHead.Items.Add(item);

新标签将为空.如何将其他元素插入此选项卡或将其他选项卡的内容应用于其中(在运行时)?

在此先感谢

Heya,

I added a Tabcontrol with a (single) Tabitem with a textbox inside, into my application. Now if I would create a new tab with:

CHead.Items.Add(item);

The new tab will be empty. How do I insert other elements into this tab or apply the content from another tab into it (at runtime)?

Thanks in advance

推荐答案

您需要查看Tabitems的TabControl项目集合

您可以添加另一个并设置其内容,例如如果我有一个带有1个选项卡页的选项卡控件,则在该选项卡页上单击一个按钮,在单击事件中可以;

You need to look at the TabControl items collection for the tabitems

You can add another and set its content, e.g. if I have a tabcontrol with 1 tab page, on that tab page a button, in the click event you could;

private void button1_Click(object sender, RoutedEventArgs e)
{
    TabItem newTab = new TabItem();

    newTab.Header = "Another Tab";

    newTab.Content = new TextBox();

    tabControl1.Items.Add(newTab);

}


这篇关于如何在运行时将内容插入Tabitems的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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