Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to remove maring between ListView.GroupHeaderTemplate and first item in list?

$
0
0

Hi, I'm trying to style ListView.GroupHeaderTemplate, so it has backgroundColor.

On iOS it looks great.
On UWP, given XAML below, I receive unwanted space between GroupHeader and first item in group. How can I remove it? I've tried setting margins, spacing and padding of probably every item in GroupHeaderTemplate but with no avail.

Here is link to repo with faulty code - https://bitbucket.org/Leroom/xamarinlistgroupheadermargin/overview
Link to XAML - https://bitbucket.org/Leroom/xamarinlistgroupheadermargin/src/f2881114a65c57dde92b2f926bd088d16f9c06a8/ListGroupHeaderMarginIssue/ListGroupHeaderMarginIssue/MainPage.xaml?at=master&fileviewer=file-view-default

And the XAML itself

`<?xml version="1.0" encoding="utf-8" ?>


<ListView.GroupHeaderTemplate>



        <Label Grid.Row="0"
               Grid.Column="0"
               Text="{Binding LineOne}"
               LineBreakMode="TailTruncation"
               FontSize="16"
               TextColor="#4d4d4d"
               VerticalOptions="CenterAndExpand" />

        <Label Grid.Row="1"
               Grid.Column="0"
               Text="{Binding LineTwo}"
               FontSize="14"
               TextColor="#808080"/>

        <Label Grid.Row="2"
               Grid.Column="0"
               Text="{Binding LineThree}"
               FontSize="14"
               TextColor="#808080"/>
      </Grid>
    </ViewCell>
  </DataTemplate>
</ListView.ItemTemplate>
<ListView.Footer></ListView.Footer>


`

and classes used to create viewModel

`using System.Collections.ObjectModel;

namespace ListGroupHeaderMarginIssue
{
public class ViewModel
{
public ViewModel()
{
ItemGroups = new ObservableCollection();
}

    public ObservableCollection<ViewModelItemGroup> ItemGroups { get; set; }
}

public class ViewModelItemGroup : ObservableCollection<ViewModelItem>
{
    public string  DisplayName { get; set; }
}

public class ViewModelItem
{
    public ViewModelItem()
    {
    }

    public ViewModelItem(string lineOne, string lineTwo, string lineThree)
    {
        LineOne = lineOne;
        LineTwo = lineTwo;
        LineThree = lineThree;
    }

    public string LineOne { get; set; }
    public string LineTwo { get; set; }
    public string LineThree { get; set; }
}

}
`


Viewing all articles
Browse latest Browse all 204402

Trending Articles