Hi I am using a basic Listview in forms with hard coded data in a list. When navigating to the page which contains the listview, it takes a nice 1-2 seconds to load. Any specific reason why this is happening?
Code:
protected override void OnAppearing ()
{
base.OnAppearing ();
//Get Menuitems for current menu
MenuListViewModel.MenuItems= Task.Run (async () => await UCommerceServices.GetMenuItemsForCategory(MenuListViewModel.ParentId)).Result;
foreach (var menuItem in MenuListViewModel.MenuItems) {
menuItems.Add (menuItem);
}
activityIndicator.IsVisible = false;
}
View:
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Pizza4U.MenuListPage">
<ContentPage.Content>
<Grid VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<ListView x:Name="listView">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout BackgroundColor="#eee" Orientation="Vertical">
<StackLayout Orientation="Horizontal">
<Image Source="{Binding ImageUrl}" />
<Label Text="{Binding Title}" TextColor="#f35e20" />
<Label Text="{Binding Description}" HorizontalOptions="EndAndExpand" TextColor="#503026" />
</StackLayout>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<ActivityIndicator IsVisible="true" IsRunning="true"
VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" x:Name="activityIndicator" />
</Grid>
</ContentPage.Content>
</ContentPage>
Note that the GetMenuItemsForCategory is retrieving a list which is currently hardcoded.
Thanks for your assistance.
Shaun