Setting Tab Content

4 posts, 0 answers
  1. None
    None avatar
    25 posts
    Member since:
    Nov 2013

    Posted 17 Dec 2013 Link to this post

    I was trying to get the "Databinding" tab control demo working that allows you to dynamically add and remove tabs, and I don't see how to set the content for the currently selected tab. This is what I would like to do.

    I have a search button. When I press the search button, I want to be able to dynamically add content to the selected tab. The content should remain when the user switches tabs as well(I am assuming for this I just need to set the IsContentPerserved flag). I would like to be able to do this in the code-behind, as I am pulling data with entity framework to populate a user control, which I will then put in the selected tab. How would I do this? Thank you.
  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1183 posts

    Posted 20 Dec 2013 Link to this post

    Hi Laura,

    As you can see in the demo, the ContentTemplate of the RadTabItem is set to a DataTemplate hosting an empty Grid component. In your particular case you can create a custom DataTemplate which will define how the content of the tabs will be structured.

    Furthermore, you will be able to fill that DataTemplate with data from your ViewModel (your entities respectively) by using Bindings.

    I hope this information is helpful.

    Regards,
    Pavel R. Pavlov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. None
    None avatar
    25 posts
    Member since:
    Nov 2013

    Posted 24 Dec 2013 Link to this post

    So every time ANY tab gets rendered(including the ones in the demo where you can add/remove them), it will render the DataTemplate, and it is the job of the view model for each tab to add it's own content? I guess I was a little confused at how I would add a new tab(like in the demo with the + button) and set the content for that new tab. Or in this case, the view model for that specific tab. Thanks.
  5. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1183 posts

    Posted 27 Dec 2013 Link to this post

    Hi,

    You need to keep in mind that the RadTabControl is used in MVVM scenario. This means that the control receives a collection of business items as ItemsSource and uses its ItemTemplate (to structure the header) and ContentTemplate (to structure the content) properties to create RadTabItems.

    In your particular case you need to expose properties in the TabViewModel that will hold the information that will be visualized in the content of the RadTabItems. Furthermore, in the DataTemplate called "ContentTemplate" you need to expose controls that will be visualized in the content of each RadTabItem. Also, you will need to use bindings to the properties exposed in the TabViewModel in order to visualize your business data. You can see how the "TabItemTemplate" is structured and follow the same approach to create your own ContentTemplate.

    I hope this information is helpful.

    Regards,
    Pavel R. Pavlov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top