maui icon indicating copy to clipboard operation
maui copied to clipboard

CollectionView.Header Pinned on Top when scrolling

Open TheStone03 opened this issue 1 year ago • 4 comments

Description

i would like to have the possibility to pin the header of the CollectionView to the top of it. so when scrolling it remains on the screen.

Public API Changes

CollectionView.PinHeader="true"

Intended Use-Case

this will be just a functionality like Excel.

TheStone03 avatar Sep 28 '23 13:09 TheStone03

Wouldn't this be the same as putting the header outside the CollectionView?

paulvarache avatar Sep 28 '23 14:09 paulvarache

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

ghost avatar Sep 28 '23 18:09 ghost

Wouldn't this be the same as putting the header outside the CollectionView?

No because if you need also the horizontal scroll in the CollectionView? having an header pinned on top is good for vertical scroll of the items, and it's needed inside the same CollectionView because if the total width of the columns is bigger than the width of the control, you can use the horizontal scroll and in the same time you can scroll the header and the body.

TheStone03 avatar Sep 29 '23 05:09 TheStone03

+1 I need this too

awp-sirius avatar Jan 27 '24 21:01 awp-sirius

+1 I need this too

mateusfrancino avatar Jun 20 '24 21:06 mateusfrancino

It is my temporary solution for pinned the header:

<ScrollView Orientation="Both" x:Name="MainScroll">
    <Grid VerticalOptions="Start" Margin="0,0,0,10">
        <CollectionView Margin="0,36,0,0"
                        HorizontalScrollBarVisibility="Never"
                        VerticalScrollBarVisibility="Never"
                        HorizontalOptions="Fill"
                        ItemsSource="{Binding Days}">
            <CollectionView.ItemsLayout>
                <LinearItemsLayout Orientation="Horizontal"/>
        </CollectionView>
        <CollectionView x:Name="DaysHeader"
                        HeightRequest="36"
                        HorizontalScrollBarVisibility="Never"
                        VerticalScrollBarVisibility="Never"
                        HorizontalOptions="Fill"
                        VerticalOptions="Start"
                        InputTransparent="True"
                        ItemsSource="{Binding Days}">
            <CollectionView.ItemsLayout>
                <LinearItemsLayout Orientation="Horizontal"/>
            </CollectionView.ItemsLayout>
        </CollectionView>
    </Grid>
</ScrollView>
MainScroll.Scrolled += MainScroll_Scrolled;
...
private void MainScroll_Scrolled(object? sender, ScrolledEventArgs e)
{
    DaysHeader.TranslationY = e.ScrollY;
}

don't forget to unsubscribe from Scrolled in OnDisappearing

If desired, you can pin any element anywhere in the same way. But this will only work if you add a temporary solution from this issue... https://github.com/dotnet/maui/issues/19515

awp-sirius avatar Jun 21 '24 08:06 awp-sirius