title: How to Refresh WPF Listview correctly
body: <p>I have a class which does some stuff in a simple <code>foreach</code> loop.
  For each iteration I add an item to a WPF <code>listview</code>.</p>
  
  <p>My problem is that values in the <code>listview</code> are only visible when the <code>Foreach</code> loop is finished. </p>
  
  <p>How can i force a refresh on the UI ? Do i have to use a background worker?</p>
  
  <p>Basically my code is like this :</p>
  
  <pre><code>foreach ( xxx in yyy )
  {
      Listview.items.add("bla bla bla"):
      ; some stuff
      ; some stuff
  }
  </code></pre>
  
  <p>For information, the "stuff" is not long and i think i don't need an async programming....just a way to refresh...</p>
  
  <hr>
  
  <p>Now i'm tring to populate an ObservableCollection then bind it to the listview in order to solve the refresh issu :</p>
  
  <pre><code>public static void myClass()
  {
  
      public static ObservableCollection&lt;String&gt; names = new ObservableCollection&lt;String&gt;(); 
  
      public static void DoMyStuff()
      {
  
          names.Add("---- Stuff begin at : " + DateTime.Now + " ---" + Environment.NewLine);
  
          var Sources_URL = myDb.url_source;
          foreach (var url in Sources_URL)
          {
              names.Add("------- Do stuff for : " + url.url_root);
              // Some Stuff
          }
      }
  
  }
  </code></pre>
  
  <p>And here is the xaml :</p>
  
  <pre><code> &lt;ListView HorizontalAlignment="Stretch"  Margin="10,10,10,10" VerticalAlignment="Stretch" Name="LstViewMain" ItemsSource="{Binding Names}" /&gt;
  </code></pre>
  
  <p>With this, problem is the same, i have to wait the end of the DoMyStuff() function to see the Listview content.</p>