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

How to add a WPF UserControl to the Tab Content

7 Answers 2478 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
hkdave95
Top achievements
Rank 2
hkdave95 asked on 19 Oct 2008, 08:12 PM
Hi

I need to add a WPF User control to the tab content programmatically.

Have you got any examples of this ?

Kind Regards

David

7 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 21 Oct 2008, 12:12 PM
Hello David,

I answered in this thread as well:

http://www.telerik.com/community/forums/thread/b311D-bgmgck.aspx

If you want, you can add the UserControls directly as items of the TabControl, you just need to bind the header of the TabItem to a property that will exist on all UserControls. If we use the example from the thread, the style needs to be slightly modified :

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

I.e. you place the UserControl (the item) as content of the TabItem, while one of its properties (Description) is bound to the header.

Hopefully this will help you in your case.

Kind regards,
Miroslav
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
hkdave95
Top achievements
Rank 2
answered on 30 Oct 2008, 07:42 AM
Hi

Sorry to be a nuisance, but do you have a programmatic example ?

Kind Regards

David
0
Miroslav
Telerik team
answered on 25 Nov 2008, 09:01 AM
Hi David,

Sorry for the delayed reply,

You can programmatically add TabItems like so:

var tabItem = new RadTabItem();  
tabItem.Header = "My Tab Header";  
tabItem.Content = new MyUserControl();  
tabControl.Items.Add(tabItem); 

The first example also adds items programmatically, but uses the ItemsSource rather than directly creating and adding the items.

I hope this is what you need,

Regards,
Miroslav
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Allen
Top achievements
Rank 2
Iron
Veteran
answered on 21 Feb 2012, 05:02 PM
Can you also style this user control with a Telerik theme at the same time? 
My usercontrols have a mixture of Windows and Telerik controls, but when I set them into the tab control like this, they only have the startup style and cannot be restyled dynamically.  The rest of the controls do respond to dynamic style change.
Any ideas?
0
Petar Mladenov
Telerik team
answered on 24 Feb 2012, 10:03 AM
Hi Allen ,

 Since this is a very old post, could you please elaborate more on your scenario? What is your RadControls version? What are the controls that you use in the TabItems' Content? What do you mean by "the  rest of the controls"? Is it possible for you to send us an isolated sample showing your issues? 
Please note that dynamic style/theme/template change is usually considered as bad practice that may lead to various issues. 

All the best,
Petar Mladenov
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Sreelaskshmi
Top achievements
Rank 1
answered on 07 Mar 2017, 06:48 AM

Hi Miroslav,

May be my question is not related to this thread.

I have a window with list of users. if i click on each user, currenlty  i am opening  a window/user cotrol to show user chat history.

Here the problem is, if we click on multiple users then multiple windows are opening and occupying the screen space.So i want to avoid this problem by using Rad Tab control.Please let me know how to add user controls/window  in view model .Please provide any sample example if you have any.

Thanks, 

Mohan G

 

0
Dilyan Traykov
Telerik team
answered on 09 Mar 2017, 10:35 AM
Hello Mohan,

Please have a look at the following three articles as they demonstrate how to bind the RadTabControl to a collection as well as how to add and remove tabs from the control:

- Data Binding
- Binding to Collection
- Add and Remove Tabs

I hope you find these resources helpful. The exact implementation really depends on the specific setup at your end, however, if you would provide more details regarding your exact requirements, I will be glad to further assist you.

Regards,
Dilyan Traykov
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
TabControl
Asked by
hkdave95
Top achievements
Rank 2
Answers by
Miroslav
Telerik team
hkdave95
Top achievements
Rank 2
Allen
Top achievements
Rank 2
Iron
Veteran
Petar Mladenov
Telerik team
Sreelaskshmi
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or