question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CollectionView shows no ScrollBar

See original GitHub issue

Description

When filling a CollectionView with more data than fits on the screen I can scroll CollectionView, but no ScrollBar is shown. Not even if I set the *ScrollBarVisibility to Always or just do this with the VerticalScrollBarVisibility only.

Steps to Reproduce

Create a new .NET MAUI .NET7 App in VS2022 and change those to files to the following (or load my reproduction repository):

MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="CollectionViewScrollBar.MainPage"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:collectionViewScrollBar="clr-namespace:CollectionViewScrollBar"
    x:DataType="collectionViewScrollBar:MainPage">

    <CollectionView
        HorizontalScrollBarVisibility="Always"
        ItemsSource="{Binding Rows}"
        VerticalScrollBarVisibility="Always">
        <CollectionView.ItemTemplate>
            <DataTemplate x:DataType="collectionViewScrollBar:Row">
                <Grid RowDefinitions="Auto, Auto">
                    <Label
                        Grid.Row="0"
                        FontAttributes="Bold"
                        Text="{Binding Title}" />
                    <Label
                        Grid.Row="1"
                        FontAttributes="Italic"
                        Text="{Binding Detail}" />
                </Grid>
            </DataTemplate>
        </CollectionView.ItemTemplate>
    </CollectionView>

</ContentPage>

MainPage.xaml.cs

using System.Collections.ObjectModel;

namespace CollectionViewScrollBar;

public partial class MainPage : ContentPage
{
	public MainPage()
	{
		InitializeComponent();
        BindingContext = this;

        for (var i = 0; i < 50; i++)
        {
            Rows.Add(new Row($"Title-{i}", $"Detail-{i}"));
        }
	}

    public ObservableCollection<Row>  Rows { get; } = new ();
}

public record Row(string Title, string Detail);

image

With a ListView it works: MainPage.xaml

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
    x:Class="CollectionViewScrollBar.MainPage"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:collectionViewScrollBar="clr-namespace:CollectionViewScrollBar"
    x:DataType="collectionViewScrollBar:MainPage">

    <ListView ItemsSource="{Binding Rows}">
        <ListView.ItemTemplate>
            <DataTemplate x:DataType="collectionViewScrollBar:Row">
                <TextCell Detail="{Binding Detail}" Text="{Binding Title}" />
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>

</ContentPage>

image

Link to public reproduction project repository

https://github.com/SokoFromNZ/MauiCollectionViewScrollBar

Version with bug

7.0 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

Android 11

Did you find any workaround?

No

Relevant log output

No response

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
SokoFromNZcommented, Nov 16, 2022

@Eilon @jsuarezruiz I was kinda schocked to see this go to the backlog!!

The official MAUI doc (https://learn.microsoft.com/en-us/dotnet/maui/user-interface/controls/collectionview/?view=net-maui-7.0) to CollectionView clearly stated to use the CollectionView over all other views! It even says “It aims to provide a more flexible, and performant alternative to ListView.” and even “CollectionView automatically utilizes the virtualization provided by the underlying native controls”.

But I cannot use any CollectionView in my whole app if the user cannot see if there is more data to scroll. So this should be a Prio-A bug.

I am feeling the pain MAUI puts on developers since day one (also see https://github.com/dotnet/maui/issues/8602). In Mai we had plans to release our product in January, But instead of implementing our business logic, all we do is try to find workarounds for MAUI bugs to get even the simpliest things done… We even cut back from releasing an Android, iOS and Windows version to just Android, but not even the rudimental things in Android work! And now you moving this to the backlog?!

I am frustrated…

0reactions
HobDevcommented, Jun 7, 2023

Facing this issue on Windows. The scrollbar is only visible when user clicks below the CollectionView. Although I set the ScollBarVisibility to always.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to hide scroll bar of UICollectionView
I m working on a UICollectionView class, and it will display the scroll bar when I scroll on the list, it's possible to...
Read more >
Control scrolling in a CollectionView - .NET MAUI
When a user swipes to initiate a scroll, the end position of the scroll can be controlled so that items are fully displayed....
Read more >
scrolling not working in UICollectionView
I load photos in that collection view. But the photos loaded go beyond the height of the controller and there is no way...
Read more >
Infinite Scrolling using CollectionView In .NET MAUI / Xamarin ...
This video about implementing Infinite Scrolling using CollectionView In .NET MAUI /Xamarin Forms.
Read more >
Scrolling UICollectionView inside
My collection view loads data, I see a nice list and when I scroll it... ... the expectation is it scrolls inside it's...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found