ItemContainerStyle not working

2 posts, 0 answers
  1. Heiko
    Heiko avatar
    124 posts
    Member since:
    Oct 2012

    Posted 22 Mar 2012 Link to this post

    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
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 27 Mar 2012 Link to this post

    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 >>
  3. DevCraft banner
Back to Top