Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Does not work GroupHeaderTemplate in ListView

$
0
0

I create ViewCell for CategoryProductsHeader and applied it. But nothing changes.

ListView listView = new CategoryListView
            {
                HasUnevenRows = true,
                ItemTemplate = new DataTemplate(typeof(CategoryProductsCell)),
                GroupHeaderTemplate = new DataTemplate(typeof(CategoryProductsHeader)),
                ItemsSource = productGroups,
                IsGroupingEnabled = true,
                GroupDisplayBinding = new Binding("Name"),
                BackgroundColor = Color.Black,
            };

`
public class CategoryProductsHeader : ViewCell
{
public CategoryProductsHeader()
{
Label text = new Label()
{
FontSize = 18,
XAlign = TextAlignment.Center,
YAlign = TextAlignment.Center,
};
text.SetBinding(Label.TextProperty, "Name");

        var line = new BoxView()
        {
            Color = Color.FromHex("#BE0000"),
            HeightRequest = 1,
        };

        StackLayout layout = new StackLayout()
        {
            Orientation = StackOrientation.Vertical,
            HorizontalOptions = LayoutOptions.FillAndExpand,
            VerticalOptions = LayoutOptions.FillAndExpand, 
            BackgroundColor=Color.Gray,
            Children = { line, text, line }
        };

        this.View = layout;
    }
}

`


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>