views:

192

answers:

1

Hi,

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.

+2  A: 

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.

wpfwannabe
Cheers! All is good now...Thanks.U.