Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

445
Visualizações
Xamarin forms -> PopUpView showing whitespace, but how to remove it?

Hope everyone is well. I'm running into a UI problem with my cross platform app for xamarin.forms. Basically it shows different on ios when compared to android.

I have a function on the AdminPage that when button clicks opens the PopupView, the popUp will either contain details on the user, or the order, for this example we are using orderDetails

   private void ShowUserDetails_Clicked(object Sender, EventArgs e)
    {
        Button button = (Button)Sender;
        string UserId = button.CommandParameter.ToString();

        PopupNavigation.Instance.PushAsync(new PopupView(-1, int.Parse(UserId)));
    }

The problem lies in the UI of the popUp, if you notice the android phone on the left of the image below. It loads the way I want it to. Displaying lable for email | phone number, followed by listview of OrderDetails below. As you can see it looks fine on the android. The problem is on the ios. Where is the whitespace coming from at the top of the PopUpView?

If you take a close look at the PopUpView on the iphone 11, there is a scroll bar to the right of the popUp . It starts where the text starts, and I cant scroll any further up. Its almost as if there is an extra row placed before anything else. I have looked extensively through the code and can't figure it out. So I want to remove the whitespace, have even tried listview.scrollTo for the listview but with no success..any help would be great thank you

enter image description here

<?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="BottleShop.Views.PopupView"
    xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
             xmlns:converters="clr-namespace:BottleShop.ViewModels.Converters">

    <StackLayout x:Name="StackSearchResultsOuter" BackgroundColor="Transparent" HorizontalOptions="Center" VerticalOptions="Center">   
            <StackLayout.Resources>
                <converters:ProductIdToProductNameConverter x:Key="converter"/>
            </StackLayout.Resources>


            <BoxView x:Name="InvisibleSpacer" BackgroundColor = "Transparent"
        HeightRequest="80" />

            <StackLayout x:Name="StackLayoutOrders" IsVisible="{Binding SLOrders}">
                <ListView BackgroundColor="White" ItemsSource="{Binding PreviousOrderDetailsForUserLV}" HasUnevenRows="True" SeparatorVisibility="None">

                    <ListView.Header>
                        <Grid>

                            <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="30*" />
                                <ColumnDefinition Width="25*" />
                                <ColumnDefinition Width="25*" />
                                <ColumnDefinition Width="20*" />
                            </Grid.ColumnDefinitions>


                        <Label Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="0" x:Name="UserInfoLabel" HorizontalOptions="Center" Margin="10,10,0,0"/>

                       <BoxView Grid.Row="1"
                             Grid.ColumnSpan="4" 
                             BackgroundColor="LightGray"/>

                        <Label Grid.Column="0" Text="Product" Grid.Row="1" HorizontalOptions="Center" Margin="0,10,0,0"/>
                            <Label Grid.Column="1" Grid.Row="1" Text="Quantity" HorizontalOptions="Center" Margin="0,10,0,0"/>
                            <Label Grid.Column="2" Grid.Row="1" Text="Price" HorizontalOptions="Center" Margin="0,10,0,0"/>
                            <Label Grid.Column="3" Grid.Row="1" Text="Sub" HorizontalOptions="Center" Margin="0,10,0,0"/>
                            <!--<BoxView Grid.Row="1"
                             Grid.ColumnSpan="4"
                             HeightRequest="1"
                             BackgroundColor="LightGray"/> -->


                        </Grid>
                    </ListView.Header>

                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <Grid Padding="10" RowSpacing="10" ColumnSpacing="10">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>

                                        <ColumnDefinition Width="43*" />
                                        <ColumnDefinition Width="8*" />
                                        <ColumnDefinition Width="25*" />
                                        <ColumnDefinition Width="24*" />

                                    </Grid.ColumnDefinitions>
                                    <Label Grid.Column="0" Grid.Row="0" HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand" Text="{Binding ProductId, Converter={StaticResource converter}}"/>
                                    <Label Grid.Column="1" Grid.Row="0" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Text="{Binding Quantity}"/>
                                    <Label Grid.Column="2" Grid.Row="0" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Text="{Binding PriceOfItem, StringFormat='£{0:0.00}'}"/>
                                    <Label Grid.Column="3" Grid.Row="0" HorizontalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand" Text="{Binding SubtotalForThisItem, StringFormat='£{0:0.00}'}"/>
                                </Grid>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </StackLayout>

            <StackLayout x:Name="StackLayoutUsers" IsVisible="{Binding SLUsers}">
                <ListView x:Name="UsersListView" BackgroundColor="White" ItemsSource="{Binding AllExistingUsersLV}" HasUnevenRows="True" SeparatorVisibility="None">
                    <ListView.Header>
                        <Grid>

                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="30*" />
                                <ColumnDefinition Width="25*" />
                                <ColumnDefinition Width="25*" />
                                <ColumnDefinition Width="20*" />
                            </Grid.ColumnDefinitions>

                            <Label Grid.Column="0" Text="Address Line 1" Grid.Row="0" HorizontalOptions="Center" Margin="0,10,0,0"/>
                        <Label Grid.Column="1" Grid.Row="0" Text="Line 2" HorizontalOptions="Center" Margin="0,10,0,0"/>
                            <Label Grid.Column="2" Grid.Row="0" Text="Town" HorizontalOptions="Center" Margin="0,10,0,0"/>
                            <Label Grid.Column="3" Grid.Row="0" Text="Mobile" HorizontalOptions="Center" Margin="0,10,0,0"/>
                            <BoxView Grid.Row="1"
                             Grid.ColumnSpan="4"
                             HeightRequest="1"
                             BackgroundColor="LightGray"/>


                        </Grid>
                    </ListView.Header>

                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <ViewCell>
                                <Grid Padding="10" RowSpacing="10" ColumnSpacing="10">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <Grid.ColumnDefinitions>

                                        <ColumnDefinition Width="43*" />
                                        <ColumnDefinition Width="8*" />
                                        <ColumnDefinition Width="25*" />
                                        <ColumnDefinition Width="24*" />

                                    </Grid.ColumnDefinitions>
                                <Label Grid.Column="0" Grid.Row="0" HorizontalOptions="StartAndExpand" VerticalOptions="EndAndExpand" Text="{Binding AddressLine1}"/>
                                <Label Grid.Column="1" Grid.Row="0" HorizontalOptions="StartAndExpand" VerticalOptions="EndAndExpand" Text="{Binding AddressLine2}"/>
                                <Label Grid.Column="2" Grid.Row="0" HorizontalOptions="EndAndExpand" VerticalOptions="EndAndExpand" Text="{Binding City}"/>
                                <Label Grid.Column="3" Grid.Row="0" HorizontalOptions="EndAndExpand" VerticalOptions="EndAndExpand" Text="{Binding MobileNumber}"/>
                                </Grid>
                            </ViewCell>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>
            </StackLayout>



        </StackLayout>
   <!-- </Grid>   -->
</pages:PopupPage>

using BottleShop.Data;
using BottleShop.Models;
using Microsoft.AppCenter.Crashes;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Xamarin.Forms.Xaml;

namespace BottleShop.Views
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class PopupView //: ContentView
    {
        public ObservableCollection<OrderDetailsModel> PreviousOrderDetailsForUserLV { get; set; }

        OrdersDatabaseController RecentOrdersController = new OrdersDatabaseController();

        public ObservableCollection<UserModel> AllExistingUsersLV { get; set; }
        UserDatabaseController UserController = new UserDatabaseController();

        public bool SLOrders { get; set; }
        public bool SLUsers { get; set; }

    public PopupView(int OrderId, int UserId)
        {
            try
            {
                InitializeComponent();


                //Show Orders PopUp
                if (OrderId != -1)
                {
                    SLOrders = true;
                    SLUsers = false;

                    List<OrderDetailsModel> RecentOrderDetailsList = RecentOrdersController.GetAllOrderDetailsByOrderId(OrderId);
                    PreviousOrderDetailsForUserLV = new ObservableCollection<OrderDetailsModel>(RecentOrderDetailsList as List<OrderDetailsModel>);

                    int startingHeightOfSL = 180;
                    int countOfOrderDetailRecords = PreviousOrderDetailsForUserLV.Count;
                    var tempHeightofStackSearchResults = countOfOrderDetailRecords * 40;

                    if (countOfOrderDetailRecords > 1)
                    {
                        StackSearchResultsOuter.HeightRequest = startingHeightOfSL + tempHeightofStackSearchResults;
                    }
                    else
                    {
                        StackSearchResultsOuter.HeightRequest = startingHeightOfSL;
                    }
                    
                    UserInfoLabel.Text = "Email: " + PreviousOrderDetailsForUserLV[0].UserName + " | " + "Mobile: " + PreviousOrderDetailsForUserLV[0].UserMobileNumber;

                }
                else //Show Users PopUp
                {
                    if(UserId != -1)
                    {
                        var a = 1;

                        SLOrders = false;
                        SLUsers = true;

                        List<UserModel> UsersList = UserController.GetUserWithId(UserId);
                        if (UsersList != null)
                        {
                            AllExistingUsersLV = new ObservableCollection<UserModel>(UsersList as List<UserModel>);
                        }

                        StackSearchResultsOuter.HeightRequest = 180;
                    }
                }

                BindingContext = this;

            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
    }
}
over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda