Updated: July 2008
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.
Visual Basic (Declaration)
<SecurityPermissionAttribute(SecurityAction.InheritanceDemand, UnmanagedCode := True)> _
Public Class D3DImage _
Inherits ImageSource
[SecurityPermissionAttribute(SecurityAction.InheritanceDemand, UnmanagedCode = true)]
public class D3DImage : ImageSource
[SecurityPermissionAttribute(SecurityAction::InheritanceDemand, UnmanagedCode = true)]
public ref class D3DImage : public ImageSource
public class D3DImage extends ImageSource
XAML Object Element Usage
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.
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"
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>
System..::.Object
System.Windows.Threading..::.DispatcherObject
System.Windows..::.DependencyObject
System.Windows..::.Freezable
System.Windows.Media.Animation..::.Animatable
System.Windows.Media..::.ImageSource
System.Windows.Interop..::.D3DImage
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
Reference
Other Resources
Date | History | Reason |
|---|
July 2008
| Added topic for new class. |
SP1 feature change.
|