ListView with AbsoluteLayout slow

Hi!

I'm starting with Xamarin and my first project applying Xamarin Forms.

I have a ContentPage carrying a ListView. The list has 9 lines. The cell displays 1 image and 1 label. It turns out that when you access the page I can see the ListView being assembled item by item and the background color of the ListView is black (the page background color is orange). This behavior began to occur when added a AbsoluteLayout on the page. Below is my code page:

<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:theme="clr-namespace:appbits.Rapiid" x:Class="appbits.Rapiid.Pages.Menu.EstoqueMenuPage" Title="{Binding Title}" IsBusy="{Binding IsBusy}" BackgroundColor="{StaticResource EstoqueBackgroundColor}"> <ContentPage.Resources> <ResourceDictionary MergedWith="theme:AppResources" /> </ContentPage.Resources> <AbsoluteLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand"> <ListView CachingStrategy="RecycleElement" ItemsSource="{Binding MenuItems}" HasUnevenRows="True" IsPullToRefreshEnabled="True" SelectedItem="{Binding SelectedMenuItem}" IsRefreshing="{Binding IsBusy, Mode=OneWay}" SeparatorVisibility="None" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0,0,1,1"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <StackLayout> <Grid Padding="10"> <Grid.ColumnDefinitions> <ColumnDefinition Width="5"/> <ColumnDefinition Width="58"/> <ColumnDefinition Width="5"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <Image Grid.Column="1" Source="{Binding Icon}" IsOpaque="True"></Image> <Label Grid.Column="3" Text="{Binding Title}" FontSize="Small" LineBreakMode="WordWrap" TextColor="White" VerticalTextAlignment="Center" HorizontalTextAlignment="Start"></Label> </Grid> <StackLayout BackgroundColor="{StaticResource EstoqueSecondColor}" HeightRequest="1" HorizontalOptions="FillAndExpand" VerticalOptions="EndAndExpand"/> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView> <StackLayout IsVisible="{Binding IsBusy}" HorizontalOptions="Center" HeightRequest="30" AbsoluteLayout.LayoutFlags="PositionProportional" AbsoluteLayout.LayoutBounds="0.5,0.5,-1,-1"> <StackLayout.Orientation> <OnPlatform x:TypeArguments="StackOrientation" iOS="Horizontal"/> </StackLayout.Orientation> <ActivityIndicator IsRunning="{Binding IsBusy}" Color="{StaticResource EstoqueFrontColor}"> </ActivityIndicator> <Label Text="Carregando opções..." HorizontalOptions="Center" TextColor="{StaticResource LabelTextColor}"/> </StackLayout> </AbsoluteLayout> </ContentPage>

If I leave the page only the ListView it is loaded normally. If you add the AbsoluteLayout to have ActivityIndicator loading the ListView is affected.

I am taking as a basis the project "Hanselman.Forms". The only difference in my project is that I am using MvvmCross to benefit from MVVM Binding and plugins.

Can anyone identify what I'm not seeing?

Thanks!

Rodrigo

Answers

  • Sorry! I forgot to mention that this behavior is occurring in the deploy on a Windows 10 Mobile (UWP). Device Lumia 640 XL 1 Gb Ram. But running on Windows Mobile emulator 10 with 1 Gb Ram is also possible to see the same behavior.

  • DanielLDanielL PLInsider ✭✭✭✭
  • Hi @DanielL!

    Thanks for your response!

    I implemented FFImageLoading the latest version 2.2.4 (which came out today) and removed the StackLayout. I kept only the StackLayout I'm using to make the ListView lines tab. But these changes did not solve the problem. ListView still carries with black background and this slow. With these changes I noticed that the label of the first row is not displayed. The other yes. When I play on the first line triggering another page to return the label appears.

    Very strange! :(

    I have a suspicion but I have not yet experience to conclude that this may be the problem. As I am using MvvmCross the codebehind of the page does not have any code. Everything is in the ViewModel that MvvmCross automatically associate with the page. So, I'm not using the OnAppearing event. I am running a Command in the constructor of my ViewModel for the list of elements that will render ListView. I do not know if this is a good approach. I do not think so.

    Searching for Google I found material on the creation of Behaviors that are linked to events and this can make binding (EventToCommandBehavior). But I have not tried. Link Xamarin: https://developer.xamarin.com/guides/xamarin-forms/behaviors/reusable/event-to-command-behavior/.

    Thanks for new suggestions.

    Rodrigo

Sign In or Register to comment.