Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Rendering Event
Collapse the table of content
Expand the table of content

CompositionTarget.Rendering Event

Occurs just before the objects in the composition tree are rendered.

Namespace:  System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public static event EventHandler Rendering
<object Rendering="EventHandler" .../>

The Rendering event is routed to the specified event handler after animation and layout have been applied to the composition tree.

The Rendering event is raised during the Windows Presentation Foundation (WPF) rendering process. The following example shows how you register an EventHandler delegate to the static Rendering method on CompositionTarget.

// Add an event handler to update canvas background color just before it is rendered.
CompositionTarget.Rendering += UpdateColor;

You can use your rendering event handler to create custom drawing content. This event handler gets called once per frame. Each time that Windows Presentation Foundation (WPF) marshals the persisted rendering data in the visual tree across to the composition tree, your event handler is called. In addition, if changes to the visual tree force updates to the composition tree, your event handler is also called. Note that your event handler is called after layout has been computed. However, you can modify layout in your event handler, which means that layout will be computed once more before rendering.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft