Dynamically create headertemplate and add to radtabitem

3 posts, 0 answers
  1. Abhilash
    Abhilash avatar
    30 posts
    Member since:
    Jan 2012

    Posted 14 Jun 2013 Link to this post


    I want to dynamically create headertemplate for the below xaml and attach it to the radtabitem.please help.

                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            <ContentControl Content="Tab 1" />
                            <telerik:RadButton Grid.Column="1" Width="16" Height="16" Margin="3 0 0 0"
                                    HorizontalAlignment="Center" VerticalAlignment="Center" Content="x"
                                     Padding="0" />
  2. Pavel R. Pavlov
    Pavel R. Pavlov avatar
    1165 posts

    Posted 18 Jun 2013 Link to this post

    Hi Abhilash,

    Can you please elaborate more on your scenario and clarify what you have in mind when you say "dynamically create". Do you need to apply different DataTemplate to the Header of any RadTabItem at runtime? If so you can use DataTemplateSelector instead. You can create a custom class deriving from the native DataTemplateSelector and override the SelectTemplate() method. In its implementation you can return the desired template based on your custom logic. Please note that you have to define the DataTemplates in XAML and use the custom selector to switch them, only.

    Furthermore, this approach is recommended to be used in MVVM scenarios. I hope this information will be in help. Feel free to ask if you have any other questions.

    Pavel R. Pavlov

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft R3 2016 release webinar banner
  4. Abhilash
    Abhilash avatar
    30 posts
    Member since:
    Jan 2012

    Posted 28 Jun 2013 Link to this post

    Hello Pavel,
    Thanks for the response.

    I took the below link as reference and it worked fine.


    Thanks again.


Back to Top