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

ItemContainerStyle not working

1 Answer 93 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Heiko
Top achievements
Rank 1
Iron
Veteran
Heiko asked on 22 Mar 2012, 09:14 AM
Hi everyone!

We are just evaluating the actual Q1.2012 Version of Silverlight Controls together with SL5 and ran into a problem using RadTabControl and its ItemContainerStyle. What was working in an older version of this control is no longer working in the actual version.
We created a very simple Style (just for testing purposes):
<UserControl.Resources>
    <Style x:Key="ClosableStyle" TargetType="telerik:RadTabItem">
        <Setter Property="HeaderTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <ContentControl Content="Hello, World!" />
                    </Grid>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</UserControl.Resources>

Then apply this to the RadTabControl like this:
<StackPanel>
    <telerik:RadTabControl Height="200" ItemContainerStyle="{StaticResource ClosableStyle}">
        <telerik:RadTabItem></telerik:RadTabItem>
    </telerik:RadTabControl>
</StackPanel>

The result is: nothing is shown in the tabheader, it should display "Hello, world!". We tried the same Style with an older version of RadTabControl (2010.3, one of your examples out of this forum) and this one is definetely working.

Any help is very appreciated!
Neils

1 Answer, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 27 Mar 2012, 09:24 AM
Hi Neils,

I am not sure how you've managed to get this working in previous version but basically the ItemContainerStyle property is used to apply a style to all RadTabItem containers when the RadTabControl ItemsSource collection contains a collection of business items. This is why the ItemContainerStyle property is useful in databinding scenarios. But when you define the RadTabItems declaratively in xaml you can define the Header, Content and the overall style of each tab in xaml and this is why the ItemContainerStyle property in such scenarios cannot be used.

I attached a sample project demonstrating a common scenario in which the ItemContainerStyle property is used to set the HeaderTemplate of the tab items. I hope it helps.

Kind regards,
Tina Stancheva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
TabControl
Asked by
Heiko
Top achievements
Rank 1
Iron
Veteran
Answers by
Tina Stancheva
Telerik team
Share this question
or