Represents the composited display surface for an app. This class is mainly for Microsoft DirectX content interop scenarios.
public : sealed class CompositionTarget : ICompositionTarget
public sealed class CompositionTarget : ICompositionTarget
Public NotInheritable Class CompositionTarget Implements ICompositionTarget
Windows 10 (introduced v10.0.10240.0)
Windows.Foundation.UniversalApiContract (introduced v1)
CompositionTarget has one member, Rendering. Rendering is a static event that is fired by the XAML rendering system overall, not by the Application, Window, Page or any other specific object part of an app. CompositionTarget 's sole purpose is to provide this hook into the rendering process. That's mainly relevant only to Microsoft DirectX content interop scenarios where you want to know when the XAML rendering happens, so that you can execute some Microsoft DirectX code in response. For scenarios that don't involve Microsoft DirectX content you probably won't need Rendering and can just rely on the XAML rendering system running and performing all your composition and layout.
Rendering Rendering Rendering
Occurs when the core rendering process renders a frame.
public : event EventHandler Rendering<Platform::Object>
public event EventHandler Rendering<object>
Public Event EventHandler Rendering( Of ( Of object ))
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 Microsoft 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 Microsoft 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 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
- See Also
SurfaceContentsLost SurfaceContentsLost SurfaceContentsLost
Occurs when an underlying major change occurs, such as a DirectX device change. Typically the application must regenerate its surface contents when notified of this event.
public : event EventHandler SurfaceContentsLost<Platform::Object>
public event EventHandler SurfaceContentsLost<object>
Public Event EventHandler SurfaceContentsLost( Of ( Of object ))