title: WPF Binding filtered ObservableCollection ICollectionView to Combobox
body: <p>I want to filter an ObservableCollection to a subset based on type (type AddPoint) and want it ordered ascending with no duplicates.  My base class is ModelBase, w/ sub-classes AddPoint, Time, Repeat, etc...  The ObservableCollection MotionSequenceCollection will be filled w/ those types in any order and some will be duplicates.</p>
  
  <p>I've tried several different times and shown them below in the ICollectionView Property that I 'pulled' from:  <a href="https://stackoverflow.com/questions/9621393/bind-subset-of-collection">Bind subset of collection</a>.  </p>
  
  <p>OBSERVABLE COLLECTION</p>
  
  <pre><code>private ObservableCollection&lt;ModelBase&gt; _motionSequenceCollection = 
          new ObservableCollection&lt;ModelBase&gt;();
  
      public ObservableCollection&lt;ModelBase&gt; MotionSequenceCollection
      {
          get
          {
              return _motionSequenceCollection;
          }
  
          set
          {
              if (_motionSequenceCollection == value)
              {
                  return;
              }
  
              var oldValue = _motionSequenceCollection;
              _motionSequenceCollection = value;
  
              // Update bindings, no broadcast
              RaisePropertyChanged();
          }
      }
  
      public ICollectionView Location
      {
          get
          {
               var location = CollectionViewSource.GetDefaultView(_motionSequenceCollection);
  
              //DOES NOT WORK.  PROBLEM: GetType() creates type of system.type() and AddPoint, which don't work.  Need a cast, or something??  
              // found at https://stackoverflow.com/questions/9621393/bind-subset-of-collection  The problem is that there is an error:
              //    Cannot apply operator '==' to operands of type 'System.Type' and 'MotionSeq.Model.AddPoint',
              //    candidates are:
              //          bool ==(System.Reflection.MemberInfo, System.Reflection.memberInfo) (in class MemberInfo)
              //          bool ==(System.type, System.Type) (in class Type)
              //location.Filter = p =&gt; (p as ModelBase).GetType() == AddPoint;
  
              //DOES NOT WORK.  PROBLEM: Affects the main collection and won't let TIME type added.
              //location.Filter = o1 =&gt; (o1 is AddPoint);
  
              //DOES NOT WORK.  PROBLEM: Sorts fine, but also sorts MotionSequenceCollection!!  What up w/ that!?  
              //location.SortDescriptions.Add(new SortDescription("AddPointClassName", ListSortDirection.Ascending));
  
              //DOES NOT WORK.  PROBLEM: MotionSequenceCollection does not update.
              //location.Filter = p =&gt; (p as ModelBase) == AddPoint;
  
              //DOES NOT WORK.  PROBLEM: Source is not instantiated(?) and exmaple from stackoverflow and not sure how that got there in the first place.
              //source.Filter = p =&gt; (p as ModelBase).GetType() == "AddPoint";
              //return source;
  
              return location;
          }
      }
  </code></pre>