CompositionTarget.Rendering event

Applies to Windows and Windows Phone

Occurs when the core rendering process renders a frame.

Syntax


public static event EventHandler<object> Rendering

Event information

DelegateSystem.EventHandler<Object> [.NET] | Windows.Foundation.EventHandler<Object> [C++]

Remarks

Handling Rendering is mainly interesting if you have interop scenarios with Microsoft DirectX content. For example you might want to know when the XAML system is rendering and synchronize that with your DirectX generated content and when your SwapChainPanel draws. For more info, see DirectX and XAML interop.

Because this event is for an interop scenario, it's rare that you would handle Rendering in C# or Microsoft Visual Basic code. You'd usually only handle it in the Visual C++ component extensions (C++/CX) code that supports the XAML portion of your UI, as part of an interop/hybrid app that also has a DirectX component.

To satisfy the compiler, the second e/args parameter of your handler for a Rendering event must be Object. Don't use EventArgs. However, within the handler, you can cast the e/args reference as RenderingEventArgs. RenderingEventArgs has one property, RenderingTime, that might be useful in your rendering scenario, but not all handlers would need this info. It may be enough just to know that the event fires and handle every occurrence.

Handlers for Rendering run on the UI thread even though they're not tied to any specific UI element. It's a good idea to remove any Rendering handlers when you no longer need them, and add them only when you do need them. For example add the handler only when specific pages with interop content are loaded, and then remove the handler as part of page cleanup (OnNavigatedFrom).

For example code of handling Rendering, see Direct3D shooting game sample. The App::OnRendering method in this sample is the handler. This handler is noteworthy because it has code in it that checks its own UI state (such as checking for whether the control has focus). For certain states the handler acts as its own one-time cleanup by calling ::remove with an app-level stored event token from the initial ::add.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Media
Windows::UI::Xaml::Media [C++]

Metadata

Windows.winmd

See also

CompositionTarget
DirectX and XAML interop
Make animations smooth
Direct3D shooting game sample

 

 

Show:
© 2014 Microsoft. All rights reserved.