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

ListView Scrolling Performance

$
0
0

I'm considering to optimize my cell in order to achieve better performance when scrolling in my list. If there is more than 100 objects scrolling is painfully slow. How can I improve my cell? Will formatting the binded strings into a single string improve performance? If so, how can I format them so that there still are 4 separated columns?

    `public MyCell() 

{

var lblName = new Label{
    HorizontalOptions = LayoutOptions.FillAndExpand
};
lblName.SetBinding(Label.TextProperty,"Name");

var lblCustom = new Label{
    HorizontalOptions = LayoutOptions.FillAndExpand
};
lblCustom.SetBinding(Label.TextProperty,"Custom");

var lblDesc = new Label{
    HorizontalOptions = LayoutOptions.FillAndExpand
};
lblDesc.SetBinding(Label.TextProperty,"Description");

var lblDate = new Label{HorizontalOptions = LayoutOptions.FillAndExpand,};
lblDate.SetBinding(Label.TextProperty,new Binding(path: "Date",stringFormat: "{0:dd/MM/yyyy}"));

var grid = new Grid
{
    Padding = new Thickness (0, 0, 0, 0);
    HorizontalOptions = LayoutOptions.FillAndExpand;
    VerticalOptions = LayoutOptions.Start;
    ColumnDefinitions.Add (new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) });
    ColumnDefinitions.Add (new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) });
    ColumnDefinitions.Add (new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) });
    ColumnDefinitions.Add (new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) });
};

grid.Children.Add (lblName,0,0);
grid.Children.Add (lblCustom,1,0);
grid.Children.Add (lblDesc, 2, 0);
grid.Children.Add (lblDate, 3, 0);

StackLayout viewLayout = new StackLayout
{
    Padding=new Thickness(3,10,3,0),
    Orientation = StackOrientation.Horizontal,
    Children = {grid} 
};

View = viewLayout;

}

}
`


Viewing all articles
Browse latest Browse all 58056

Trending Articles