Greetings everybody.

I'm new to .net and WPF and I've bumped into a problem I can't seem to figure out.
I wan't to clear all items from a listBox just prior to refresing it's data.

Using XAML, the listBox is bound to a DataSet named movies as seen below:

<ListBox ItemTemplate="{StaticResource listBoxTemplate}" ItemsSource="{Binding movies}" Name="listBox1" Margin="36,61,322,123" />


Now in my C# code, if I use listBox1.Items.Clear() I get this error:

"Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead."

I'm not 100% sure what to make of the above error message. Someone told me to clear the bindings, in order to clear the values in the listBox, but then I can't get the values to appear in the listbox in the first place.

Hope it made sense.

Thx in advance.