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

Show List in ListView

$
0
0

Hello ! I have ListView in the Grid in Xaml . How can I do finish my code to implement information in the ListView ?

`<?xml version="1.0" encoding="utf-8" ?>

<ContentPage.Content>

<Grid.RowDefinitions>

</Grid.RowDefinitions>
<Grid.ColumnDefinitions>

        </Grid.ColumnDefinitions>
        <ListView Grid.Row="0" Grid.RowSpan="5" Grid.Column="0" Grid.ColumnSpan="1" x:Name="list"/>

    </Grid>
</ContentPage.Content>

`

`using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace App1
{
public partial class MainPage : ContentPage
{
ObservableCollection Items;
bool isLoading;
Page page;
public MainPage()
{
InitializeComponent();
Items = new ObservableCollection();
var listview = new ListView();

        listview.ItemsSource = Items;
        listview.ItemAppearing += (sender, e) =>
        {
            if (isLoading || Items.Count == 0)
                return;

            //hit bottom!
            if (e.Item.ToString() == Items[Items.Count - 1])
            {
                LoadItems();
            }
        };

        // The root page of your application
        page = new ContentPage
        {
            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center,
                Children = {
                    listview
                }
            }
        };




        ///////////////// Here I must implement List in ListView





        LoadItems();
    }
    async Task LoadItems()
    {
        isLoading = true;
        page.Title = "Loading";

        //simulator delayed load

        for (int i = 0; i < 20; i++)
        {
            Items.Add(string.Format("Item {0}", Items.Count));
        }
        page.Title = "Done";
        isLoading = false;
    }
}

}
`


Viewing all articles
Browse latest Browse all 77050

Trending Articles