3

CollectionView UI gets overlapped when perform scroll in iOS -> iPad device. Check the attached image.

enter image description here

MyPage.xaml

<Grid IsVisible="{Binding IsBusy, Converter={StaticResource inverseBooleanConverter}}"
         RowDefinitions="auto, auto, auto, *, auto, auto">

        <StackLayout
                    Padding="0"
                    BackgroundColor="WhiteSmoke"
                    Grid.Row="0">
            <StackLayout
                        Orientation="Horizontal"
                        Margin="10,20">

                <ImageButton
                            HorizontalOptions="Start"
                            HeightRequest="22"
                            WidthRequest="22"
                            Command="{Binding Path=NavigateToRootCommand}"
                            Margin="5,0">
                    <ImageButton.Source>
                        <FontImageSource Glyph="{x:Static helper:MaterialFontHelper.ChevronDown}"
                                         Color="{StaticResource Black}"
                                         Size="22"
                                         FontFamily="MaterialDesignIcons"/>

                    </ImageButton.Source>
                </ImageButton>

                <Label
                      Style="{StaticResource LabelValueStyle}"
                      Text="Retail Food"
                      HorizontalOptions="Start"/>

                <Label
                      Style="{StaticResource LabelValueStyle}"
                      Text="NA"
                      HorizontalOptions="EndAndExpand"/>

            </StackLayout>
            <StackLayout.Shadow>
                <Shadow
                       Brush="Black"
                       Offset="10,5"
                       Opacity="0.3" />
            </StackLayout.Shadow>
        </StackLayout>
        <Label
              Grid.Row="1"
              Padding="10,20,0,20"
              LineBreakMode="TailTruncation"
              Text="{Binding Path=InspectionTitle}"
              Style="{StaticResource LabelTitleStyle}"/>

        <BoxView
                Grid.Row="2"
                HeightRequest="0.3"
                BackgroundColor="#ECECEC"/>

        <CollectionView
            Grid.Row="3"
            HorizontalOptions="FillAndExpand"
            VerticalOptions="FillAndExpand"
            ItemsSource="{Binding HealthViolationCodeRefs}">
                <CollectionView.ItemTemplate>
                    <DataTemplate>
                        <Grid
                             RowDefinitions="auto, auto, 5"
                             RowSpacing="5"
                             ColumnDefinitions="40, *, 5">

                            <CheckBox
                                     Grid.Row="0"
                                     VerticalOptions="CenterAndExpand"
                                     Margin="0,5,0,0"
                                     IsChecked="{Binding Path=IsSelected}"
                                     CheckedChanged="CheckBox_CheckedChanged"
                                     Color="DarkGray"
                                     Grid.Column="0">
                            </CheckBox>

                            <Label
                                  Padding="10,10,0,0"
                                  Text="{Binding Path=CodeNumber}"
                                  Style="{StaticResource LabelTitleStyle}"
                                  Grid.Row="0" Grid.Column="1">
                                <Label.GestureRecognizers>
                                    <TapGestureRecognizer
                                                         Command="{Binding Source={x:Reference _this},
                                                                   Path=BindingContext.ViolationCodeTapCommand}"
                                                                   CommandParameter="{Binding .}"/>
                                </Label.GestureRecognizers>
                            </Label>

                            <Label
                                  Grid.Row="1"
                                  Grid.Column="1"
                                  Padding="10,0"
                                  Margin="{OnPlatform iOS='0,0,20,0'}"
                                  Style="{StaticResource LabelKeyStyle}"
                                  HorizontalOptions="StartAndExpand"
                                  MaxLines="4"
                                  Text="{Binding Path=CodeText}"/>

                            <BoxView
                                    HeightRequest="0.3"
                                    Grid.Row="2"
                                    Grid.Column="0"
                                    Grid.ColumnSpan="3"
                                    BackgroundColor="#ECECEC"/>
                        </Grid>
                    </DataTemplate>

                </CollectionView.ItemTemplate>
        </CollectionView>
      <StackLayout BackgroundColor="WhiteSmoke" Grid.Row="5" VerticalOptions="EndAndExpand" Orientation="Horizontal">
            <Button
                    Margin="0,10,15,10"
                    Command="{Binding Path=NavigateToViolationItemDetailsCommand}"
                    Text="Next"
                    IsEnabled="{Binding Path=IsNextEnabled}"
                    Padding="30,10"
                    HorizontalOptions="EndAndExpand"
                    CornerRadius="5"/>
    </StackLayout>
</Grid>

I have tried to remove bounce and animation using Handler like we do in Xamarin.Forms using custom renderer

namespace YourAppName.iOS.Renderers
{
    public class NoBounceScrollViewRenderer : ScrollViewRenderer
    {
        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                // Disable bounce effect
                Bounces = false;
            }
        }
    }
}

But there is no such properties like Bounce or AlwaysBounceVertical in .NET MAUI CollectionView. Does anyone know how to fix this?

Reported new bug in Maui: https://github.com/dotnet/maui/issues/15983

Divyesh
  • 2,085
  • 20
  • 35
  • I have added code related to CollectionView, screenshot of the output is already attached. – Divyesh Jul 03 '23 at 17:03
  • 1
    If you do not scroll, the items are not overlapping? I see in the screenshot that collectionview is not correctly calculating height of the items; when there is a longer item, the next one overlaps it. Create a new issue at https://github.com/dotnet/maui/issues. Please make a public github repo with just enough code for devs to run it and see the problem; put a link to that repo in your new issue. Then come back here and put a link to your new issue. Thanks. – ToolmakerSteve Jul 03 '23 at 18:09
  • @ToolmakerSteve I have crated new issue at maui git hub repo and added link here. – Divyesh Jul 04 '23 at 11:44

1 Answers1

0
RowDefinitions="auto, auto, auto, *, auto, auto">

Row 3 is fill.

<CollectionView
            Grid.Row="3"
            HorizontalOptions="FillAndExpand"
            VerticalOptions="FillAndExpand"
            ItemsSource="{Binding HealthViolationCodeRefs}">

VerticalOptions is fill.

I have seen more than one complain about this. (If you want, I can do the search for you)

  1. Remove VerticalOptions and test.
  2. Add HeightRequest=300 and test.
  3. Make sure you do not have any AUTO before * and test. (or was the other way around)

You will not like this, but more or less all you can do is to make it work somehow. You may have to redesign the whole thing. I am waiting myself for more than one fix for the collection view. It is bug infested.

H.A.H.
  • 2,104
  • 1
  • 8
  • 21
  • Fix height is not solution anyone like, and none of this working. – Divyesh Jul 04 '23 at 06:50
  • Are you sure HeightRequest is not working? When everything else fails, this works. Messing up the height calculation is one thing, setting it to something specific and not responding is something else. Double check it, and tell me if it still overlaps. Also, did you remove VerticalOptions as I told you? – H.A.H. Jul 04 '23 at 07:19
  • It might work but fix height is not what I want. I don't said it not works but that is not a proper solution. Instead of fix height I can use bindable stack layout. – Divyesh Jul 04 '23 at 07:44
  • @Divyesh Well, you have two options. Option A, you use MAUI and do what we all do - write work arounds. Option B - you don't use MAUI. – H.A.H. Jul 04 '23 at 08:32
  • @Divyesh Have you tried using a BindableLayout in combination with StackLayout or FlexLayout? StackLayout has its own issues at the moment in MAUI and I found that FlexLayout sometimes works well as a substitute (depending on the UI requirements). – Julian Jul 04 '23 at 08:34
  • We can use it with StackLayout. What issue does StackLayout have? – Divyesh Jul 04 '23 at 09:52
  • @Divyesh you cannot use it with StackLayout (Vertical). It is not restricted vertically. You will be rendering the whole CollectionView at the same time. Again you will have to vertically restrict it. Best case scenario you will need to programmatically calculate the height. https://github.com/dotnet/maui/issues/12071#issuecomment-1488190679 This is just one of the fake bug reports. – H.A.H. Jul 04 '23 at 13:38