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

RadCarousel: height of CarouselItems

3 Answers 25 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Craig Cote
Top achievements
Rank 2
Craig Cote asked on 11 Jul 2008, 07:47 AM
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?

3 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 11 Jul 2008, 12:11 PM
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
0
Craig Cote
Top achievements
Rank 2
answered on 11 Jul 2008, 04:17 PM
Thanks for the suggestions.  I'll let you know what works best for me.
0
Craig Cote
Top achievements
Rank 2
answered on 11 Jul 2008, 08:04 PM
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...
Tags
General Discussions
Asked by
Craig Cote
Top achievements
Rank 2
Answers by
Milan
Telerik team
Craig Cote
Top achievements
Rank 2
Share this question
or