title: How to clear WPF listbox?
body: <p>Hai am using wpf list box, i cannot able to clear the list when am calling the reload data function, i just want to reload new data at runtime,while page loading it loads the data correctly, when i refresh the new data is fetched in itemsource i can see that in debug mode, but no new data in listbox, old data remains in the list, i cant even clear, when i call list.items.clear(), it throws exception and app crashes, i tried lot ways, is ther any problem in my XAML binding, the following is my code. </p>
  
  <pre><code>&lt;DataTemplate x:Key="listBoxTemplate"&gt;
                  &lt;StackPanel Margin="3"&gt;
                      &lt;DockPanel &gt;
                          &lt;TextBlock FontWeight="Bold" Text="{Binding Name}" DockPanel.Dock="Left" Margin="5,0,10,0"/&gt;
                          &lt;TextBlock Text="  " /&gt;
                           &lt;TextBlock Text="{Binding Percnt}" Foreground="Green" FontWeight="Bold" /&gt;
                     &lt;/DockPanel&gt;                       
                  &lt;/StackPanel&gt;
              &lt;/DataTemplate&gt;
  </code></pre>
  
  <p>My listbox</p>
  
  <pre><code> &lt;ListBox Height="898" Name="lstEntity" Width="291" ItemTemplate="{StaticResource listBoxTemplate}" SelectionChanged="lstEntity_SelectionChanged"/&gt;
  </code></pre>
  
  <p>Binding code</p>
  
  <pre><code>   lstEntity.ItemsSource = sei.getNames();
  </code></pre>
  
  <p>getNames() function just returns the data as list,nothing special code in that, How to resolve this. </p>