views:

1175

answers:

2

This seems does not work: TabItem tabItem = new TabItem(); tabItem.Header = "New tab"; tabItem.Content = "Content"; tabControl.Items.Add(tabItem);

Anyone has done adding TabItem dynamically to a TabControl?

+3  A: 

Works for me

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

Tabs.Items.Add(item);
Graeme Bradbury
A: 

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);
Sap