Applying ControlTemplate to RadCarousel

3 posts, 1 answers
  1. James Ludlow
    James Ludlow avatar
    8 posts
    Member since:
    Dec 2009

    Posted 21 Jul 2010 Link to this post

    Having a little problem when I try to apply a control template to the rad carousel, in that as soon as I put in the binding to the template, the carousel no longer displays any items.

    Here is the code for the carousel:
                Template="{StaticResource FavouritesCarousel}">
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FF7D7D7D" Offset="0.164"/>
                    <GradientStop Color="White" Offset="0.093"/>
                <telerik:ReflectionSettings Visibility="Visible" OffsetY="3"/>

    And the control template code:
    <ControlTemplate x:Key="FavouritesCarousel" TargetType="{x:Type telerik2:RadCarousel}">
                HorizontalScrollBarVisibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik2:RadCarousel}}, Path=HorizontalScrollBarVisibility}"
                VerticalScrollBarVisibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik2:RadCarousel}}, Path=VerticalScrollBarVisibility}">

    Any suggestions? Thanks.
  2. Answer
    Maya avatar
    4062 posts

    Posted 23 Jul 2010 Link to this post

    Hi James Ludlow,

    Internally, the structure of the RadCarousel is a bit different and that is why the way you are setting the Template is not working as expected. So, what you can do in this case is to define it as follows:

            <Style TargetType="{x:Type telerik:CarouselItemsControl}">
                <Setter Property="Template">
                        <ControlTemplate TargetType="{x:Type telerik:CarouselItemsControl}">
                                    HorizontalScrollBarVisibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:RadCarousel}}, Path=HorizontalScrollBarVisibility}"
                                       VerticalScrollBarVisibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:RadCarousel}}, Path=VerticalScrollBarVisibility}">                             

    Furthermore, there is no need to set the Template property of the Carousel as the way the style is defined here, it will be applied immediately.

    Kind regards,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. James Ludlow
    James Ludlow avatar
    8 posts
    Member since:
    Dec 2009

    Posted 26 Jul 2010 Link to this post

    Ah, that's fantastic. Thanks very much for your help.
Back to Top