【问题标题】:How to add a tabitem to a silverlight tabcontrol in code如何在代码中将 tabitem 添加到 silverlight tabcontrol
【发布时间】:2010-10-19 06:32:21
【问题描述】:

这似乎不起作用: TabItem tabItem = new TabItem(); tabItem.Header = "新标签页"; tabItem.Content = "内容"; tabControl.Items.Add(tabItem);

有人已经将 TabItem 动态添加到 TabControl 中了吗?

【问题讨论】:

    标签: silverlight controls


    【解决方案1】:

    为我工作

    TabItem item = new TabItem();
    item.Header = "Test Header";
    item.Content = "Some Text";
    
    Tabs.Items.Add(item);
    

    【讨论】:

      【解决方案2】:
      TabControl tc = new TabControl(); 
      tc.Width = 400;
      tc.Height = 300;
      
      TabItem ti = new TabItem();
      ti.Header = "Tab Header";
      ti.Content = "Tab Content";
      
      tc.Items.Add(ti);
      LayoutRoot.Children.Remove(tc);
      LayoutRoot.Children.Add(tc);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-01-28
        • 2020-04-05
        • 1970-01-01
        • 2011-02-14
        • 2018-05-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多