RadCarousel: height of CarouselItems

4 posts, 0 answers
  1. Craig Cote
    Craig Cote avatar
    8 posts
    Member since:
    Oct 2004

    Posted 11 Jul 2008 Link to this post

    Copied from my XAML code:

    <

    Style TargetType="{x:Type Telerik:CarouselItem}">
        <Setter Property="Template" >
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Telerik:CarouselItem}">
                    <Grid ClipToBounds="False" Height="175" Width="350" >

    Strangely, the Width property on the last line does make my carousel items wider/narrower, but the Height property does not.  Is this an issue (and thus subject to being fixed) or is it broken by design?

  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 11 Jul 2008 Link to this post

    Hello Craig Cote,

    The default style of the CarouselItem explicitly sets the Height of the control and this is the reason why changing the Height in the ControlTemplate does not have any effect. There are two easy solutions that come to my mind:

    The first one is to use the OverridesDefaultStyle property like this:

    <Style TargetType="{x:Type Telerik:CarouselItem}">  
        <Setter Property="OverridesDefaultStyle" Value="True"/>  
        <Setter Property="Template" > 
            <Setter.Value> 
                <ControlTemplate TargetType="{x:Type Telerik:CarouselItem}">  
                    <Grid ClipToBounds="False" Height="175" Width="350" > 
                        ....  
                    </Grid> 
                </ControlTemplate> 
            </Setter.Value> 
          </Setter> 
    </Style> 

    That way you can override the property setters that are applied by the default style and you will be able to change the Height.

    The second one is to explicitly set Height and Width in the Style for CarouselItem

    <Style TargetType="{x:Type Telerik:CarouselItem}">  
        <Setter Property="Height" Value="100"/>  
        <Setter Property="Width" Value="400"/>  
        <Setter Property="Template" > 
            <Setter.Value> 
                <ControlTemplate TargetType="{x:Type Telerik:CarouselItem}">  
                    <Grid ClipToBounds="True">  
                        <ContentPresenter IsHitTestVisible="True" /> 
                    </Grid> 
                </ControlTemplate> 
            </Setter.Value> 
        </Setter> 
    </Style> 

    Best wishes,
    Milan
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Craig Cote
    Craig Cote avatar
    8 posts
    Member since:
    Oct 2004

    Posted 11 Jul 2008 Link to this post

    Thanks for the suggestions.  I'll let you know what works best for me.
  4. Craig Cote
    Craig Cote avatar
    8 posts
    Member since:
    Oct 2004

    Posted 11 Jul 2008 Link to this post

    I've used the "OverridesDefaultStyle" property, and it works great for me. 

    Still, it seems odd that even before setting this flag changing the Width property of the Grid had an effect but changing the Height property did not...
Back to Top