Пример #1
0
        private void Children_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
                Debug.Assert(e.NewItems.Count == 1);
                ChildApps.Add(new AppItemViewModel((IAudioDeviceSession)e.NewItems[0], isChild: true));
                break;

            case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
                Debug.Assert(e.OldItems.Count == 1);
                ChildApps.Remove(ChildApps.First(x => x.Id == ((IAudioDeviceSession)e.OldItems[0]).Id));
                break;

            default:
                throw new NotImplementedException();
            }
        }
Пример #2
0
        private void Children_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (_parent.TryGetTarget(out var parent))
            {
                switch (e.Action)
                {
                case NotifyCollectionChangedAction.Add:
                    Debug.Assert(e.NewItems.Count == 1);
                    ChildApps.Add(new AppItemViewModel(parent, (IAudioDeviceSession)e.NewItems[0], true, Icon));
                    break;

                case NotifyCollectionChangedAction.Remove:
                    Debug.Assert(e.OldItems.Count == 1);
                    ChildApps.Remove(ChildApps.First(x => x.Id == ((IAudioDeviceSession)e.OldItems[0]).Id));
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
        }