This is a migrated thread and some comments may be shown as answers.

How to insert RadGrid inside RadTabItem

8 Answers 339 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Yana
Top achievements
Rank 1
Yana asked on 18 Aug 2011, 02:47 AM
Hi guys, 

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


Y

8 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 23 Aug 2011, 12:42 PM
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 >>

0
Yana
Top achievements
Rank 1
answered on 23 Aug 2011, 03:26 PM
Can you please attach a simple example? Thanks!
0
Accepted
Tina Stancheva
Telerik team
answered on 26 Aug 2011, 12:19 PM
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 >>

0
Yana
Top achievements
Rank 1
answered on 02 Sep 2011, 03:09 AM
Thanks so much! Just what I needed. 

Cheers!

Y
0
Marian
Top achievements
Rank 1
answered on 09 May 2012, 01:30 PM
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

0
Tina Stancheva
Telerik team
answered on 14 May 2012, 03:40 PM
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 >>

0
Richard
Top achievements
Rank 1
answered on 07 Jun 2012, 03:23 PM
Hi,

I have a similar problem to Maros. I would like to force the RadTabControl to add the tab contents to the visual tree immediately and not wait for the TabItem to be selected. I'm happy to extend the RadTabControl class if that is necessary. I've seen that a few people have extended the standard WPF TabControl to work this way so it must be possible. I just need some direction on extending the control.

Regards
Andy
0
Hristo
Telerik team
answered on 12 Jun 2012, 12:45 PM
Hello,

There are several properties that are internal or private to the control that you could not access from the derived class. Also the code forcing visual controls realization may not be very pretty or straight forward.

The more easy and straight forward way would be to select all tab items consequently one by one.

Personally I would prefer to work with my view models when possible and not deal with visuals that are not yet visible. Forcing visuals to be created in advance and be invisible could harm performance and cause unexpected results.

Greetings,
Hristo
the Telerik team

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

Tags
TabControl
Asked by
Yana
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Yana
Top achievements
Rank 1
Marian
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or