Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > TabControl > How to insert RadGrid inside RadTabItem

Answered How to insert RadGrid inside RadTabItem

Feed from this thread
  • Posted on Aug 17, 2011 (permalink)

    Hi guys, 

    Can you please help me on how to insert RadGrid and RadButton inside a RadTabItem of the RadControl?
    Pretty please. Thanks.


    Y

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on Aug 23, 2011 (permalink)

    Hello Yana,

    You can populate the RadTabControl with Items declaratively in XAML like so:
    <telerik:RadTabControl>
        <telerik:RadTabItem Header="GridView">
            <telerik:RadGridView />
        </telerik:RadTabItem>
        <telerik:RadTabItem Header="Button">
            <telerik:RadButton Content="RadButton" />
        </telerik:RadTabItem>
        <telerik:RadTabItem Header="Controls">
            <StackPanel>
                <telerik:RadGridView />
                <telerik:RadButton Content="RadButton1" />
            </StackPanel>
        </telerik:RadTabItem>
        <telerik:RadTabItem Header="Quote" Content="Quote Text" />
    </telerik:RadTabControl>
    Or you can bind the ItemsSource collection of the control to a collection of business items and use the RadTabControl ItemTemplate and ContentTemplate properties to define what should be displayed as the Header and Content of the RadTabItems (read more). In this case you can define the RadGridView and the RadButtons in the ContentTemplate DataTemplate and bind their properties to the business items.

    I hope this information will help you get started on your task.

    Kind regards,
    Tina Stancheva
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

    Reply

  • Posted on Aug 23, 2011 (permalink)

    Can you please attach a simple example? Thanks!

    Reply

  • Answer Tina Stancheva Tina Stancheva admin's avatar

    Posted on Aug 26, 2011 (permalink)

    Hi Yana,

    I attached a sample project how to implement this scenario with databinding in this forum thread. This is why I attached to this thread a sample illustrating how to define the described layout declarative in xaml. I hope this will help you. Please let us know if we can further assist you.

    All the best,
    Tina Stancheva
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

    Attached files

    Reply

  • Posted on Sep 1, 2011 (permalink)

    Thanks so much! Just what I needed. 

    Cheers!

    Y

    Reply

  • Maros avatar

    Posted on May 9, 2012 (permalink)

    Hello,

    I have a problem with RadGridView inside RadTabItem - and in your example (WpfApplication3.zip) is the same problem. RadGridView on 3rd RadTabItem has no items before you select it.

    Try to change your code:
    public MainWindow()
    {
        InitializeComponent();
        this.radGridView1.ItemsSource = GenerateProducts();
        this.radGridView2.ItemsSource = GenerateProducts();
        MessageBox.Show(radGridView1.Items.Count.ToString());
        MessageBox.Show(radGridView2.Items.Count.ToString());
    }

    radGridView1 on 1st RadTabItem has 19 items, but radGridView2 on 3rd RadTabItem has 0 items. In my project I have same problem with version 2011.3.1220.35 and 2012.1.0326.35 too. In previous version used in my project (2010.3.1110.35) it works fine.

    Can you help me, please?


    Thanks,
    Maros

    Reply

  • Tina Stancheva Tina Stancheva admin's avatar

    Posted on May 14, 2012 (permalink)

    Hi Maros,

    This behavior is expected because when the RadTabControl is loaded, it adds the content of its tabs in the logical tree of the application, but it doesn't add the controls in the visual tree. The content of a TabItem is added in the visual tree of the application only after the TabItem is selected. And the RadGridView Items collection is generated only when the control is added to the visual tree of the application.

    I hope that information will help you.

    Greetings,

    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WPF > TabControl > How to insert RadGrid inside RadTabItem
Related resources for "How to insert RadGrid inside RadTabItem"

WPF TabControl Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]