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

ListView bug ?

$
0
0

Hi

Trying the most simple ting, to have a listview and to add / remove items during runtime. But the listview GUI is not updated with the data in the list.

What am I missing here ( please see the code below ) ?

( testet on Windows phone and Android )


/// <summary>
/// 
/// </summary>
public class SelectPage : ContentPage
{
    List<string> TmpList
        = new List<string>();

    public SelectPage()
    {
        TmpList.Add("1");
        TmpList.Add("2");
        TmpList.Add("3");

        var listCentral = new ListView
        { 
            ItemsSource = TmpList,
        };

        var xx = new Button
        {
            Text = "Add"
        };

        var yy = new Button
        {
            Text = "Clear"
        };

        xx.Clicked += xx_Clicked;
        yy.Clicked += yy_Clicked; 

        Content = new StackLayout
        {
            Spacing = 15,
            Children = { xx, yy, listCentral }
        };
    }

    void xx_Clicked(object sender, EventArgs e)
    {
        TmpList.Add(DateTime.Now.ToString()); 
    }

    void yy_Clicked(object sender, EventArgs e)
    {
        TmpList.Clear();
    }

}


Viewing all articles
Browse latest Browse all 58056

Trending Articles