WeakEventManager.ProtectedAddListener Method

Adds the provided listener to the provided source for the event being managed.

Namespace: System.Windows
Assembly: WindowsBase (in windowsbase.dll)

protected void ProtectedAddListener (
	Object source,
	IWeakEventListener listener
protected void ProtectedAddListener (
	Object source, 
	IWeakEventListener listener
protected function ProtectedAddListener (
	source : Object, 
	listener : IWeakEventListener
You cannot use methods in XAML.



The source to attach listeners to.


The listening class (which must implement IWeakEventListener).

Call this method within your manager class AddListener methods on WeakEventManager implementations. AddListener is the suggested name for the static method you define on your manager class to enable other classes to add a listener for your weak event pattern. AddListener should take two parameters: the source where the listener is attached, and the listener instance. For your AddListener implementation, call ProtectedAddListener on the current manager, passing through the same two parameters.

If the list of listeners was previously empty, ProtectedAddListener calls StartListening internally, which will call your specific StartListening override through polymorphism.

ProtectedAddListener adds listeners to a single internal WeakEventManager.ListenerList per source. If your manager implementation maintains more than one list of listeners for each event-source combination, do not use ProtectedAddListener. Instead, your implementation should create its own WeakEventManager.ListenerList instances, AddListener should add listeners to the appropriate list, and events should be delivered to the appropriate listener list by calling DeliverEventToList rather than DeliverEvent.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0