RefreshView is pushing content to right in .NET MAUI app

Viewed 86

Came across this strange behavior in .NET MAUI app while testing it on an iOS device.

First, everything looks fine on Android -- both emaulator and physical device. I then noticed this issue in iOS Simulator and have the same results on my iPhone.

If I have no RefreshView around my CollectionView, the empty view message display where it's supposed -- well almost because I can never place it in the center of the page vertically but other than that, it displays correctly -- see below:

enter image description here

If I do place my CollectionView within a RefreshView, the Label gets pushed to the right -- see below:

enter image description here

Here's the actual code with the RefreshView. All you need to do is remove RefreshView and label is displayed in the center.

<RefreshView
        IsRefreshing="{Binding IsRefreshing}"
        Command="{Binding RefreshCouponsCommand}">
        <CollectionView
            x:Name="MyCouponsList"
            ItemsSource="{Binding Feed}"
            BackgroundColor="Transparent"
            VerticalOptions="StartAndExpand"
            Margin="0,5,0,0">
            <CollectionView.EmptyView>
                <VerticalStackLayout
                    VerticalOptions="CenterAndExpand">
                    <Label
                        Text="No data..."
                        TextColor="{StaticResource Gray600}"
                        HorizontalTextAlignment="Center" />
                </VerticalStackLayout>
            </CollectionView.EmptyView>
        </CollectionView>
    </RefreshView>

Any idea what could be causing this?

1 Answers

try replacing

<CollectionView
            x:Name="MyCouponsList"
            ItemsSource="{Binding Feed}"
            BackgroundColor="Transparent"
            VerticalOptions="StartAndExpand"
            Margin="0,5,0,0">
            <CollectionView.EmptyView>
                <VerticalStackLayout
                    VerticalOptions="CenterAndExpand">
                    <Label
                        Text="No data..."
                        TextColor="{StaticResource Gray600}"
                        HorizontalTextAlignment="Center" />
                </VerticalStackLayout>
            </CollectionView.EmptyView>
        </CollectionView>

with

<CollectionView
            x:Name="MyCouponsList"
            ItemsSource="{Binding Feed}"
            BackgroundColor="Transparent"
            VerticalOptions="CenterAndExpand"
            HorizontalOptions="CenterAndExpand"
            Margin="0,5,0,0"
            EmptyView="No Data..."/>
            
        </CollectionView>
Related