title: Silverlight DataGrid SelectedItems.Add is very slow
body: <p>I'm working on a custom control based on DataGrid, which has its own unique functionality, but also includes some buttons that will come with the control whenever its used. The buttons implement filters, select all, and clear selection. I'm having performance issues with the latter two.</p>
  
  <p>Here is the code that responds to a MVVMLight message indicating that a provided list of objects need to have their selection toggled. In the case of SelectAll and ClearSelection, I use Linq functions to get the appropriate list of points. I know as a fact that the slow part is in the foreach loop. The code above and below the loop changes state of the custom control so that other functions concerned with selection are ignored.</p>
  
  <pre><code>            SelectionChanged -= GridSelectionChanged;
              _isUpdating = true;
              var points = obj.Content;
              foreach (var point in points)
              {
                  if (point.IsSelected)
                  {
                      SelectedItems.Add(point);
                  }
                  if (!point.IsSelected)
                  {
                      SelectedItems.Remove(point);
                  }
              }
              _isUpdating = false;
              SelectionChanged += GridSelectionChanged;
  </code></pre>
  
  <p>Ctrl+A works wonderfully, which makes this doubly frustrating. Is this all due to SelectedItems.add/remove being slow? Is there some way around this?</p>
  
  <p>Let me know if more information is necessary. Thanks.</p>