How to add a tab item programatically

4 posts, 0 answers
  1. hkdave95
    hkdave95 avatar
    245 posts
    Member since:
    Nov 2006

    Posted 19 Oct 2008 Link to this post


    I need to add a tab control programmatically.

    The item I am adding is a class containing amongst other things the Description to be diaplayed on the tab.

    Do you have any examples of this.

    Kind Regards

  2. Miroslav
    Miroslav avatar
    922 posts

    Posted 21 Oct 2008 Link to this post

    Hi David,

    Yes, you can add a TabItems programmatically like so:

    tabControl.Items.Add(new RadTabItem()  
            Header = "My Header",  
            Content = "My Content" 

    Of course it is always better to use business objects and bindings. To do so:

    1. Set the ItemsSource property to an (observable) collection of your items
    2. Provide style or DataTemplate bindings for the control (in xaml).

    For example style bindings can be specified this way:

    <nav:RadTabControl x:Name="tabControl">  
            <Style TargetType="nav:RadTabItem">  
                <Setter Property="Header" 
                        Value="{Binding Description}" />  
                <Setter Property="Conent" 
                        Value="{Binding Content}" />  

    For the above code you need an object that has Description and Content properties.

    All the best,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. dbernett
    dbernett avatar
    11 posts
    Member since:
    Oct 2008

    Posted 17 Oct 2012 Link to this post

    Brand new to WPF.  I have a main window with your Ribbon Tab at top with buttons to open different windows. 

    Could you please tell me the technique to open windows inside a Rad Tab Control below the Ribbon Tab.  I need to dynamically build out the tabs as different windows are opened, and to close the tabs.

    Thanks so much!

  4. Stefan
    Stefan avatar
    89 posts

    Posted 19 Oct 2012 Link to this post

    Hello David,

    If I get you right, you need something like this example. If you need to check the example in WPF you can run our demos from here and navigate to RadTabControl's DataBinding example. The only thing you might need to change is to move the button that adds a new RadTabItem from RadTabItem's header in the RadRibbonTabs.

    If you need further assistance don't hesitate to contact us.

    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top