Exception : value was invalid value for footer template

lyrc.csslyrc.css USMember
edited June 2015 in Xamarin.Forms

This exception appear when try to use a ViewCell in FooterTemplate

ListView
_productsListView = new ListView { ItemTemplate = new DataTemplate(() => new OffertedProductCell()), HasUnevenRows = true, BindingContext = _viewModel, FooterTemplate = new DataTemplate(() => new ListViewFooterCell()) };

Template
`public class ListViewFooterCell : ViewCell
{
public ListViewFooterCell()
{
var descriptionLabel = new Label
{
TextColor = Color.White,
HorizontalOptions = LayoutOptions.EndAndExpand,
VerticalOptions = LayoutOptions.Center,
FontAttributes = FontAttributes.Bold,
FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label))
};
descriptionLabel.SetBinding(Label.TextProperty, "SummaryInfo");

        var layout = new StackLayout
        {
            Orientation = StackOrientation.Horizontal,
            BackgroundColor = AppColors.MainColor,
            Children = { descriptionLabel }
        };

        View = layout;
    }
}`

ViewModel
public string SummaryInfo { get { return string.Format("Cant. de Ofertas : {0:n0}", Products.Count); } }

Tagged:

Answers

  • lyrc.csslyrc.css USMember

    someone :(

  • adamkempadamkemp USInsider, Developer Group Leader mod

    The template for a header or footer should just be a View. Cell inherits directly from Element, not from View. Just change your base class from ViewCell to View.

Sign In or Register to comment.