Und ich mag "Repeat Yourself" nicht.Nofear23m schrieb:
Du weist ja, ich mag klickiBunti Designer nicht.
Daher habich einen CollectionChanged-Handler gebastelt, an den man jetzt alle ListCollectionViews hängen kann:
VB.NET-Quellcode
- Public Sub New()
- '...
- UrgentOrdersView = New ListCollectionView(UrgentOrderList)
- AddHandler DirectCast(UrgentOrdersView, ICollectionView).CollectionChanged, AddressOf CollectionChanged
- End Sub
- Private Sub CollectionChanged(sender As Object, e As NotifyCollectionChangedEventArgs)
- Select Case e.Action
- Case NotifyCollectionChangedAction.Add
- Dim itm = e.NewItems(0)
- Dim tp = itm.GetType
- If Not tp.IsVisible Then Return
- Dim dbSet = _context.Set(tp)
- dbSet.Add(itm)
- Case NotifyCollectionChangedAction.Remove
- Dim itm = e.OldItems(0)
- Dim tp = itm.GetType
- If Not tp.IsVisible Then Return
- Dim dbSet = _context.Set(tp)
- dbSet.Remove(itm)
- End Select
- End Sub