void AddWithNotification(WritableKeyValuePair <TKey, TValue> keyvaluepair)
 {
     dictionary.Add(keyvaluepair);
     CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add,
                                                                  keyvaluepair));
     PropertyChanged(this, new PropertyChangedEventArgs("Count"));
 }
        void UpdateWithNotification(WritableKeyValuePair <TKey, TValue> newkeyvaluepair)
        {
            if (this.ContainsKey(newkeyvaluepair.Key))
            {
                var index    = IndexOf(newkeyvaluepair.Key);
                var oldvalue = dictionary[index];
                dictionary[index] = newkeyvaluepair;

                CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace,
                                                                             newkeyvaluepair, oldvalue, index));
            }
            else
            {
                AddWithNotification(newkeyvaluepair);
            }
        }
 public void Insert(int index, WritableKeyValuePair <TKey, TValue> item)
 {
     throw new NotImplementedException();
 }
 public int IndexOf(WritableKeyValuePair <TKey, TValue> item)
 {
     return(dictionary.IndexOf(item));
 }
 bool ICollection <WritableKeyValuePair <TKey, TValue> > .Remove(WritableKeyValuePair <TKey, TValue> item)
 {
     return(RemoveWithNotification(item.Key));
 }
 bool ICollection <WritableKeyValuePair <TKey, TValue> > .Contains(WritableKeyValuePair <TKey, TValue> item)
 {
     return(((ICollection <WritableKeyValuePair <TKey, TValue> >)dictionary).Contains(item));
 }
 void ICollection <WritableKeyValuePair <TKey, TValue> > .Add(WritableKeyValuePair <TKey, TValue> item)
 {
     AddWithNotification(item);
 }