Composition |
public class CompositionRenderingHelper
The CompositionRenderingHelper type exposes the following members.
Name | Description | |
---|---|---|
IsSubscribed | Returns true if the specified subscriber is already subscribed to this CompositionRenderingHelper. | |
Subscribe | Subscribe the specified subscriber to be called on each CompositionTarget.Rendering event. The method prevents multiple subscription of the same object. | |
Unsubscribe | Unsubscribe the specified subscriber from being called on each CompositionTarget.Rendering event. |
Name | Description | |
---|---|---|
Instance | Static instance of CompositionRenderingHelper | |
PreventMultipleRenderingCallsOnSameFrame | Gets or sets a boolean that specifies if duplicate Rendering calls on the same frame are prevented. Default valus is true. |
CompositionRenderingHelper class helps work with CompositionTarget.Rendering event with allowing subscribed objects to be collected by Garbage Collection and therefore preventing infinite rendering subscription in case when the Rendering is not unsubscribed.
To use the CompositionRenderingHelper, the class that wants to subscribe to CompositionTarget.Rendering need to implement ICompositionRenderingSubscriber interface.
Then the class can be subscribed to the CompositionTarget.Rendering event with calling the Subscribe(ICompositionRenderingSubscriber) method. To unsubscribe call the Unsubscribe(ICompositionRenderingSubscriber) method.
CompositionRenderingHelper stores the subscribed classes as WeakReferences. This way the class is automatically unsubscribed when it is recylced by Garbage collector.
When there is no subscribed assigned the CompositionRenderingHelper is not subscribed to the CompositionTarget.Rendering event.
NOTE
It's possible for Rendering to call back twice in the same frame.
With setting PreventMultipleRenderingCallsOnSameFrame to true (by default), such duplicate calls are prevented.