title: How to set a new list in a WPF ListBox?
body: <p>I am implementing a simple MVVM WPF application with simple databrowsing commands.</p>
  
  <p>There is a xaml-window with a listbox</p>
  
  <pre><code>    &lt;ListBox x:Name="listBoxPersons" ItemsSource="{Binding Path=Persons}" SelectedIndex="{Binding Path=SelectedPerson, Mode=OneWayToSource}"  Grid.Column="1" Grid.Row="0" Grid.ColumnSpan="2" Margin="0,10,10,5" IsSynchronizedWithCurrentItem="True"&gt;
          &lt;ListBox.ItemTemplate&gt;
              &lt;DataTemplate&gt;
                  &lt;StackPanel Orientation="Horizontal"&gt;
                      &lt;TextBlock Text="{Binding Path=Name, UpdateSourceTrigger=PropertyChanged}" /&gt;
                  &lt;/StackPanel&gt;
              &lt;/DataTemplate&gt;
          &lt;/ListBox.ItemTemplate&gt;
      &lt;/ListBox&gt;
  </code></pre>
  
  <p>Besides there is a textbox to insert the where-clause</p>
  
  <pre><code>    &lt;TextBox Grid.Column="2" Grid.Row="6" Margin="0,5,10,5" Name="textBoxWhereClause" /&gt;
  </code></pre>
  
  <p>Persons is a ObservableCollection. I implemented simple Add / Delete / Change Commands for the persons. This works.</p>
  
  <p>Question: what do i have to do, if the user performs a new query resulting in a completely new collection? How can a bind the new collection dynamically to the listbox?</p>
  
  <p>I am a WPF beginner and helpless.</p>
  
  <p>Any help is very appreciated!</p>