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

    Hello,

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

    <telerik:RadTabItem.Header>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <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" />
                        </Grid>
                    </telerik:RadTabItem.Header>
  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1182 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.

    Regards,
    Pavel R. Pavlov
    Telerik

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft 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.

    http://www.telerik.com/help/silverlight/radtabcontrol-how-to-add-close-button-to-the-tab-headers.html

    Thanks again.

    Regards,

    Abhilash
Back to Top