Removing selectedItem from ObservableCollection using MVVM
<p>I want to remove an item from an ObservableCollection while adhering to MVVM. I understand the task, I think I understand the logic pretty well and have implemented it, but the item is never removed in the view.</p>

<p>I have traced the application with breakpoints and the value of selectedProject is being read correctly. I also added variables to check the Collection size before and after the remove statement, which were the same value so it therefore does not remove the item. My question is why? What have I missed? What rules have I not adhered to? Pretty new to .NET.</p>

<p>**I am using a WCF Service, to return an ObservableCollection of Projects from my CodeFirst DB and this is called as soon as a user opens the Projects view.</p>

<p><strong>View</strong></p>

<pre><code>&lt;ListBox ItemsSource="{Binding ProjectList, UpdateSourceTrigger=PropertyChanged}" SelectedItem="{Binding SelectedProject}" SelectedIndex="{Binding ProjectIndex}" BorderThickness="0" Margin="60,195,218.8,212.4"&gt;
        &lt;ListBox.ItemTemplate&gt;
            &lt;DataTemplate&gt;
                &lt;TextBlock Text="{Binding ProjectName}"/&gt;
            &lt;/DataTemplate&gt;
        &lt;/ListBox.ItemTemplate&gt;
    &lt;/ListBox&gt;
    &lt;Button Command="{Binding DeleteCommand}" Content="Up" HorizontalAlignment="Left" Margin="563,195,0,0" VerticalAlignment="Top" Height="35" Width="75"/&gt;
</code></pre>

<p><strong>ViewModel</strong></p>

<pre><code>private ObservableCollection&lt;Project&gt; _projectList;
public ObservableCollection&lt;Project&gt; ProjectList
    {
        get 
        {
            var q = client.ReturnProjects().ToList();
            _projectList = new ObservableCollection&lt;Project&gt;(q.ToList());
            return _projectList;
        }
        set
        {
            _projectList = value;
            OnPropertyChanged("ProjectList");
        }

public int SelectedProject
    {
        get { return _selectedProject; }
        set
        {
            _selectedProject = value;
            OnPropertyChanged("SelectedProject");
        }
    }
</code></pre>

<p>The method executed by the command is as follows, the command is being hit and the method called.</p>

<pre><code>public void DeleteProject()
        {

            if (SelectedProject != null)
            {
                ProjectList.Remove(SelectedProject);
            }
        } 
</code></pre>