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

Dynamically create headertemplate and add to radtabitem

2 Answers 116 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Abhilash
Top achievements
Rank 1
Abhilash asked on 14 Jun 2013, 10:20 AM
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 Answers, 1 is accepted

Sort by
0
Pavel R. Pavlov
Telerik team
answered on 18 Jun 2013, 12:27 PM
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.

0
Abhilash
Top achievements
Rank 1
answered on 28 Jun 2013, 07:21 AM
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
Tags
TabControl
Asked by
Abhilash
Top achievements
Rank 1
Answers by
Pavel R. Pavlov
Telerik team
Abhilash
Top achievements
Rank 1
Share this question
or