Closed RsZoli closed 7 years ago
I don't know how you are using it but there's no need for HeighRequest. Can you provide an example?
thank you for the fast response, here is the issue:
with heightrequest: http://i.imgur.com/hiEH5MM.jpg without heightrequest: http://i.imgur.com/4zyQoIf.jpg
Whats the rest of the xaml? I mean, whats is wrapping the Carousel?
Actually, it depends on the content you are using the Carousel. If you are using StackLayout, of course you need HeightRequest or how the control will know? It adapts to grid rows with height set to * or auto.
I'm sorry but I'm in the same case... and if I don't set the "heightRequest" of the carouselview, it fill all the screen area...
To prop my said, I've done a simple test :
So I've create a new test page, to confirm the correct "auto height rendering" of my "WeekView" (this view that is used later in my carousel as the Template) :
<ContentPage.Content>
<Grid ColumnSpacing="0" RowSpacing="0" Margin="0" Padding="2" BackgroundColor="#ff003c61">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<views:WeekView Grid.Row="0"/>
<StackLayout Grid.Row="1" BackgroundColor="Red"/>
</Grid>
</ContentPage.Content>
And the result is OK, my "WeekView" adapt it size to the content (NavigationBar Before, and Red Layout After) :
But if I define this "WeekView" as my carousel Template, and put the carouselview in the same "Grid Architecture" :
<ContentPage.Content>
<Grid ColumnSpacing="0" RowSpacing="0" Margin="0" Padding="2" BackgroundColor="#ff003c61">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<controls:CarouselViewControl
x:Name="CarouselWeek"
Orientation="Horizontal"
ShowIndicators="False"
InterPageSpacing="2"
IsSwipingEnabled="true"
Position="{Binding CarouselWeekPosition}"
ItemTemplate="{Binding CarouselWeekTemplate}"
ItemsSource="{Binding WeekViewModels}"
PositionSelected="CarouselWeek_PositionSelected"
Grid.Row="0"
HeightRequest="100"
/>
<StackLayout Grid.Row="1" BackgroundColor="Red"/>
</Grid>
</ContentPage.Content>
With HeightRequest :
Without HeightRequest :
I've tried to set the carousel "VerticalOptions" to "Start", "Center" or anything else... nothing better.
Any idea why it doesn't "auto-height" correctly ? Is this due to carousel templates using ?
Easy to reproduce (if not, there is my sample code) TestCalPCL.zip
CarouselView.FormsPlugin V4.4.6 Xamarin.Forms V2.4.0.38779
Is there any way to make this dynamic, according to content height?