How to add a WPF UserControl to the Tab Content

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

    Posted 19 Oct 2008 Link to this post

    Hi

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

    Have you got any examples of this ?

    Kind Regards

    David
  2. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 21 Oct 2008 Link to this post

    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.
  3. hkdave95
    hkdave95 avatar
    245 posts
    Member since:
    Nov 2006

    Posted 30 Oct 2008 Link to this post

    Hi

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

    Kind Regards

    David
  4. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 25 Nov 2008 Link to this post

    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.
  5. Allen
    Allen avatar
    50 posts
    Member since:
    Mar 2011

    Posted 21 Feb 2012 Link to this post

    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?
  6. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2981 posts

    Posted 24 Feb 2012 Link to this post

    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 >>
  7. Sreelaskshmi
    Sreelaskshmi avatar
    6 posts
    Member since:
    Aug 2014

    Posted 07 Mar in reply to Miroslav Link to this post

    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

     

  8. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    587 posts

    Posted 09 Mar Link to this post

    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 allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top