I have a CarouselView which selects a Template while Runtime that includes a CollectionView.
<ContentPage.Resources>
<DataTemplate x:Key="xxTemplate">
<CollectionView ItemsSource="{Binding .}"
HeightRequest="{Binding Source={TemplatedParent}, Path=Height}">
<CollectionView.ItemTemplate>
<DataTemplate>
...
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</DataTemplate>
<DataTemplate x:Key="yyTemplate">
<CollectionView ItemsSource="{Binding .}">
<CollectionView.ItemTemplate>
<DataTemplate>
...
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</DataTemplate>
<util:xyDataTemplateSelector x:Key="xySelector"
xx="{StaticResource xxTemplate}"
yy="{StaticResource yyTemplate}" />
</ContentPage.Resources>
This CarouselView consumes the Templates above:
<CarouselView ItemsSource="{Binding xy}"
ItemTemplate="{StaticResource xySelector}"
x:Name="xyCarouselView">
<CarouselView.ItemsLayout>
<LinearItemsLayout Orientation="Horizontal"
SnapPointsType="MandatorySingle"
SnapPointsAlignment="Center"
/>
</CarouselView.ItemsLayout>
</CarouselView>
The Problem is that the Height of the CollectionView is not fitted to the CarouselViews Height. I wanted to achieve this with a binding. But it doesn't work.
The critical Line is HeightRequest="{Binding Source={TemplatedParent}, Path=Height}".
Can someone Help me?
Thx in advance.