alexrainman / CarouselView

CarouselView control for Xamarin Forms
MIT License
436 stars 177 forks source link

It does not work without setting HeightRequest #194

Closed RsZoli closed 7 years ago

RsZoli commented 7 years ago

Is there any way to make this dynamic, according to content height?

alexrainman commented 7 years ago

I don't know how you are using it but there's no need for HeighRequest. Can you provide an example?

RsZoli commented 7 years ago

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

alexrainman commented 7 years ago

Whats the rest of the xaml? I mean, whats is wrapping the Carousel?

alexrainman commented 7 years ago

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.

ghost commented 6 years ago

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) : testpage

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>

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