How to bind a List to a WPF treeview using Xaml?

Posted by Joan Venge on Stack Overflow See other posts from Stack Overflow or by Joan Venge
Published on 2010-03-20T01:15:31Z Indexed on 2010/03/20 1:21 UTC
Read the original article Hit count: 302

Filed under:
|
|
|

I don't know how to bind a List of Drink to a WPF TreeView.

struct Drink
{
    public string Name { get; private set; }
    public int Popularity { get; private set; }

    public Drink ( string name, int popularity )
        : this ( )
    {
        this.Name = name;
        this.Popularity = popularity;
    }
}

List<Drink> coldDrinks = new List<Drink> ( ){
    new Drink ( "Water", 1 ),
    new Drink ( "Fanta", 2 ),
    new Drink ( "Sprite", 3 ),
    new Drink ( "Coke", 4 ),
    new Drink ( "Milk", 5 ) };
        }
    }

I have searched the web, for instance saw here. But what's this even mean: ItemsSource="{x:Static local:TreeTest.BoatList}"

x:? static? local?

How do you specify a collection in your code in the xaml?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET