This documentation is archived and is not being maintained.

D3DImage Class

Updated: January 2010

An ImageSource that displays a user-created Direct3D surface.

Namespace:  System.Windows.Interop
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: Not mapped to an xmlns.

[SecurityPermissionAttribute(SecurityAction::InheritanceDemand, UnmanagedCode = true)]
public ref class D3DImage : public ImageSource

Use the D3DImage class to host Direct3D content in a Windows Presentation Foundation (WPF) application.

Call the Lock method to change the Direct3D content displayed by the D3DImage. Call the SetBackBuffer method to assign a Direct3D surface to a D3DImage. Call the AddDirtyRect method to track updates to the Direct3D surface. Call the Unlock method to display the changed areas.

The D3DImage class manages two display buffers, which are called the back buffer and the front buffer. The back buffer is your Direct3D surface. Changes to the back buffer are copied forward to the front buffer when you call the Unlock method.

Occasionally, the Direct3D device is unavailable causing the front buffer to be unavailable. This lack of availability can be caused by screen locking, full-screen exclusive Direct3D applications, user-switching, or other system activities. When this occurs, your WPF application is notified by handling the IsFrontBufferAvailableChanged event, and the rendering system releases its reference to the back buffer. When the Direct3D device is available again, the rendering system raises the IsFrontBufferAvailableChanged event to notify the WPF application. Your application restarts rendering by calling the SetBackBuffer method again with a valid Direct3D surface.


Performance depends greatly on the settings of the Direct3D surface. For more information, see Performance Considerations for Direct3D9 and WPF Interoperability.


The D3DImage class does not display Direct3D content over a Remote Desktop connection.

The following code example shows how to declare a D3DImage in XAML. You must map the System.Windows.Interop namespace, because it is not included in the default XAML namespaces. For more information, see Walkthrough: Hosting Direct3D9 Content in WPF.

    <Window x:Class="D3DHost.Window1"
    Title="Window1" Height="300" Width="300" Background="PaleGoldenrod">
        <Image x:Name="imgelt">
                <i:D3DImage x:Name="d3dimg" />

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5 SP1, 3.0 SP2




January 2010

Added note about Remote Desktop connection.

Information enhancement.

July 2008

Added topic for new class.

SP1 feature change.