Forum Cross Platform with Xamarin

ListView: Why do the separators have padding at the left but not at the right?

(Question is in the title.) At first, I thought there was something I was doing wrong but I've seen this same behavior in multiple "sample" projects at which I've looked. It just seems odd that the ListView behaves this way but there may be a good reason for it. I've tried using Margin on the ListView and the enclosing ScrollView without successfully affecting this. My solution uses RelativeLayout and constrains the ScrollView right and lower borders to the needed reduction. But this seems wrong and seems there should be a relative means of doing this. 'Course, really seems I shouldn't have to do this at all.

I've shared the main XAML below. Maybe someone will see something I missed.

<?xml version="1.0" encoding="utf-8"?>
<ContentPage xmlns=""
        <OnPlatform x:TypeArguments="Thickness" iOS="0, 20, 0, 0" Android="0, 0, 0, 0" />
    <RelativeLayout BackgroundColor="Red">
        <StackLayout Orientation="Horizontal" BackgroundColor="Aqua" >
            <Button Command="{Binding AccountsCommand}" Text="Accounts" IsEnabled="{Binding IsAuthorized}" WidthRequest="100" />
            <Label Text="Count" FontAttributes="Bold" VerticalTextAlignment="Center"/>
            <Label Text="{Binding Accounts.Count}" VerticalTextAlignment="Center" />
            RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Constant=-54}"
            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Constant=-10}" >
            <ListView ItemsSource="{Binding Accounts}"
                BackgroundColor="Silver" >
                        <TextCell Text="{Binding Name}" Detail="{Binding Id}" />
            IsVisible="{Binding IsBusy}"
            IsRunning="{Binding IsBusy}"
            RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent, Property=Width, Factor=0.5}"
            RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent, Property=Height, Factor=0.5}" />


  • CharwakaCharwaka INMember ✭✭✭✭✭
    edited December 2018

    From Xamarin Forms 3.4 you can use following code

    <ContentPage ...
        <StackLayout Margin="20">
            <ListView ... ios:ListView.SeparatorStyle="FullWidth">
Sign In or Register to comment.