urema
urema

Reputation: 731

Binding to an observableCollection<string> listview

If i have a ListView (called "MainList") and want to bind to elements in a collection, how is this done.

Main.Items.Add(new ObserableCollection() { "hello", "world" }

then

Why doesnt this work? Ive tried loads of other combinations of bindings as well....

Thanks

U.

Upvotes: 0

Views: 1194

Answers (1)

wpfwannabe
wpfwannabe

Reputation: 14867

One thing you haven't tried is this:

Main.ItemsSource = new ObservableCollection<string> { "hello", "world" };

In your own code you actually added the whole collection as an item in a ListView. Surely that was not your real intention.

Upvotes: 2

Related Questions