Updated: January 2010
An ImageSource that displays a user-created Direct3D surface.
Assembly: PresentationCore (in PresentationCore.dll)
XMLNS for XAML: Not mapped to an xmlns.
Use the class to host Direct3D content in a Windows Presentation Foundation (WPF) application.
Call the Lock method to change the Direct3D content displayed by the . Call the SetBackBuffer method to assign a Direct3D surface to a . Call the AddDirtyRect method to track updates to the Direct3D surface. Call the Unlock method to display the changed areas.
The 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 class does not display Direct3D content over a Remote Desktop connection.
The following code example shows how to declare a 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" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:i="clr-namespace:System.Windows.Interop;assembly=PresentationCore" Title="Window1" Height="300" Width="300" Background="PaleGoldenrod"> <Grid> <Image x:Name="imgelt"> <Image.Source> <i:D3DImage x:Name="d3dimg" /> </Image.Source> </Image> </Grid> </Window>
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003