In my .Net Maui project I'm using a CollectionView within a ControlTemplate. The implementation is looking like this:
<ContentView.ControlTemplate>
<ControlTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<SearchBar
x:Name="ObjectSearchBar"
Grid.Row="0"
IsSpellCheckEnabled="False"
Keyboard="Text"
Placeholder="{TemplateBinding SearchBarPlaceholderText}"
TextChanged="ObjectSearchBar_TextChanged" />
<CollectionView
x:Name="ObjectResultView"
Grid.Row="1"
Margin="10,10,10,10"
ItemSizingStrategy="MeasureAllItems"
ItemTemplate="{StaticResource templateSelector}"
ItemsLayout="VerticalList"
ItemsSource="{TemplateBinding DataSource}"
SelectionChanged="ObjectResultView_SelectionChanged"
SelectionMode="Single">
</CollectionView>
</Grid>
</ControlTemplate>
<ContentView.ControlTemplate>
I'm using this ContentView within a ContentPage. The Page contains 2 StackLayouts and it's implementation is looking like this:
<ContentPage.Content>
<Grid>
<StackLayout
HorizontalOptions="FillAndExpand"
IsVisible="{Binding AddNewSectionIsVisible, Converter {converter:InvertedBoolConverter}}"
Orientation="Vertical"
VerticalOptions="FillAndExpand">
<controls:ObjectSearchControl
DataSource="{Binding DataSource}"
FilterChangedCommand="{Binding FilterChangedCommand}"
HorizontalOptions="FillAndExpand"
ObjectSelectedCommand="{Binding SelectedCommand}"
SearchBarPlaceholderText="ABC"
VerticalOptions="FillAndExpand" />
</StackLayout>
<StackLayout
HorizontalOptions="FillAndExpand"
IsVisible="{Binding AddNewSectionIsVisible}"
Orientation="Vertical"
Style="{StaticResource rootStackLayout}"
VerticalOptions="Center">
....
</StackLayout>
</Grid>
</ContentPage.Content>
Only one of the StackLayouts is displayed when the Page is Appearing.
So, if I set the height of the second row to a fixed value or set the height of the CollectionView to a fixed value scrolling is working fine. But if I use a "*" or "Auto" for the height definition of the second row the CollectionView isn't scrolling anymore.
Please, can someone help me in this case? I also tried using ScrollViews, setting the VerticalOptions of the Stacklayouts or the Grid to "FillAndExpand" like it's described in MS documentation but nothing seems to work for me.