1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
private ObservableCollection<Client> _clients;
public ObservableCollection<Client> AllClients()
{
get { return _clients;}
set {
if( _clients != null )
{
// on désabonne l'ancien objet
value.CollectionChanged -= new NotifyCollectionChangedEventHandler(AllClients_CollectionChanged);
}
_clients = value;
if( value != null )
{
// on abonne le nouvelle objet
value.CollectionChanged += new NotifyCollectionChangedEventHandler(AllClients_CollectionChanged);
}
}
}
private void AllClients_CollectionChanged( object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
switch( e.Action )
{
case NotifyCollectionChangedAction.Add :
foreach (Client client in e.NewItems)
{
client.PropertyChanged += new PropertyChangedEventHandler(ClientPropertyChanged);
}
break;
case NotifyCollectionChangedAction.Remove:
foreach (Client client in e.OldItems)
{
client.PropertyChanged -= new PropertyChangedEventHandler(ClientPropertyChanged);
}
break;
}
}
void ClientPropertyChanged(object sender, PropertyChangedEventArgs e)
{
Client client = sender as Client;
switch( e.PropertyName )
{
}
} |
Partager