How to manage height of CarouselView(image) inside Relative View in Xamrin.Forms?

developer007developer007 Member ✭✭
edited March 2018 in Xamarin.Forms

I have following 2 XAML code.

1 is without CarouselView: in this view, I am getting enough height of the image control inside Relative Layout.

2- Without CarouselView: in this view, I have added image control inside CarouselView Item Template. Now I want to set same height as I was getting in View without Carousel.

Can anybody please suggest me what I am missing here?

1- Without CarouselView: Working fine
_RelativeLayout HorizontalOptions="FillAndExpand">
_Image x:Name="profileImage" Source="{Binding ProfileImage}" Aspect="AspectFill" RelativeLayout.WidthConstraint= "{ConstraintExpression Type=RelativeToParent, Property=Width}" HeightRequest="400" IsVisible="{Binding IsImageVisible}"/>
_StackLayout Orientation="Vertical" Spacing="0" Padding="10,10,0,0" VerticalOptions="Center">
_Image Source="{Binding LocationImage}" />
_Label Text="test" HorizontalTextAlignment="Center" FontSize="12"/>
_/StackLayout>
_/RelativeLayout>

I have replace "<" with "_" in above design because I was not able to add above code.

2- With CarouselView: Not getting height of Image.

<RelativeLayout HorizontalOptions="FillAndExpand">
  <forms:CarouselView x:Name="MainCarosel" ItemsSource="{Binding Pictures}" Position="{Binding Position}">
    <forms:CarouselView.ItemTemplate>
      <DataTemplate>
        <Image Source="{Binding .}" Aspect="AspectFill" RelativeLayout.WidthConstraint=
        "{ConstraintExpression Type=RelativeToParent, Property=Width}" HeightRequest="400"></Image>
      </DataTemplate>
    </forms:CarouselView.ItemTemplate>
  </forms:CarouselView>
  <local:CarouselIndicators IndicatorHeight="16" IndicatorWidth="16" UnselectedIndicator="unselected_circle.png" SelectedIndicator="selected_circle.png" Position="{Binding Position}" ItemsSource="{Binding Pictures}" />
  <StackLayout Orientation="Vertical" Spacing="0" Padding="10,10,0,0" VerticalOptions="Center">
    <Image Source="{Binding LocationImage}" />
    <Label Text="test" HorizontalTextAlignment="Center" FontSize="12"/>
  </StackLayout>
</RelativeLayout>
Sign In or Register to comment.