title: Listview Delete Item Index source is in use wpf
body: <p>I wanna delete items from my <code>observablecollection</code></p>
  <pre><code>ObservableCollection&lt;GetterSetter&gt; _getterSetter = new ObservableCollection&lt;GetterSetter&gt;();
  
  public ObservableCollection&lt;GetterSetter&gt; showList
      {
          get { return this._getterSetter; }
      }
  </code></pre>
  <p>So my xaml file is like this,</p>
  <pre><code>&lt;ListView x:Name=&quot;listView&quot; Grid.Row=&quot;1&quot; SelectionChanged=&quot;listView_SelectionChanged&quot; Foreground=&quot;Black&quot; ItemsSource=&quot;{Binding ListViewCollection}&quot; SelectedItem=&quot;{Binding SelectedListViewItem,Mode=TwoWay}&quot; SelectionMode=&quot;Single&quot;&gt;
  &lt;ListView.View&gt;
       &lt;GridView&gt;
          &lt;GridViewColumn Header=&quot;Name&quot; Width=&quot;180&quot; DisplayMemberBinding=&quot;{Binding ShowName}&quot;/&gt;
       &lt;/GridView&gt;
  </code></pre>
  <p>and i have a ShowName getter setter in here,</p>
  <pre><code>private string _showName;
  
  public String ShowName{
      get { return _showName; }
      set
      {
        if (value == _showName) return;
        _showName = value;
        OnPropertyChanged();
      }
  </code></pre>
  <p>I wanna delete the selected item like this and it gives me an error,</p>
  <pre><code>listView.Items.Remove(listView.SelectedItems[0]);
  showList.RemoveAt(listView.Items.IndexOf(listView.SelectedItems[0]));
  </code></pre>
  <p>I also tried this</p>
  <pre><code>var delete = SelectedListViewItem;
  listView.Items.Remove(delete);
  </code></pre>
  <p>and both gave me this error,</p>
  <blockquote>
  <p>An unhandled exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll</p>
  <p>Additional information: Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead.</p>
  </blockquote>
  <p>by the way <code>GetterSetter</code> is my cs file where is my third code snippet lies,</p>
  <pre><code>public GetterSetter SelectedListViewItem
      {
          get { return _selectedListViewItem; }
          set
          {
              if (Equals(value, _selectedListViewItem)) return;
              _selectedListViewItem = value;
              OnPropertyChanged();
          }
      }
  </code></pre>