Ejemplo n.º 1
0
        protected void AddWeakEventListener(INotifyPropertyChanged source, PropertyChangedEventHandler handler)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }

            // Add listener to internal list
            PropertyChangedEventListener listener = new PropertyChangedEventListener(source, handler);

            property_changed_listeners.Add(listener);

            // Add listener to event manager
            PropertyChangedEventManager.AddListener(source, listener, "");
        }
Ejemplo n.º 2
0
        protected void RemoveWeakEventListener(INotifyPropertyChanged source, PropertyChangedEventHandler handler)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }

            // Find listener in internal list
            PropertyChangedEventListener listener = property_changed_listeners.LastOrDefault(l => l.Source == source && l.Handler == handler);

            if (listener != null)
            {
                // Remove listener from internal list and event manager
                property_changed_listeners.Remove(listener);
                PropertyChangedEventManager.RemoveListener(source, listener, "");
            }
        }