* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
2.7 KiB
title, titleSuffix, ms.date, helpviewer_keywords, ms.assetid
| title | titleSuffix | ms.date | helpviewer_keywords | ms.assetid | ||
|---|---|---|---|---|---|---|
| Host Direct3D9 content in WPF | 03/30/2017 |
|
60983736-0ab5-42cc-8b16-e9fbde261a43 |
Walkthrough: Hosting Direct3D9 Content in WPF
This walkthrough shows how to host Direct3D9 content in a Windows Presentation Foundation (WPF) application.
In this walkthrough, you perform the following tasks:
-
Create a WPF project to host the Direct3D9 content.
-
Import the Direct3D9 content.
-
Display the Direct3D9 content by using the xref:System.Windows.Interop.D3DImage class.
When you are finished, you will know how to host Direct3D9 content in a WPF application.
Prerequisites
You need the following components to complete this walkthrough:
-
Visual Studio.
-
DirectX SDK 9 or later.
-
A DLL that contains Direct3D9 content in a WPF-compatible format. For more information, see WPF and Direct3D9 Interoperation and Walkthrough: Creating Direct3D9 Content for Hosting in WPF.
Creating the WPF Project
The first step is to create the project for the WPF application.
To create the WPF project
Create a new WPF Application project in Visual C# named D3DHost. For more information, see Walkthrough: My first WPF desktop application.
MainWindow.xaml opens in the WPF Designer.
Importing the Direct3D9 Content
You import the Direct3D9 content from an unmanaged DLL by using the DllImport attribute.
To import Direct3D9 content
-
Open MainWindow.xaml.cs in the Code Editor.
-
Replace the automatically generated code with the following code.
[!code-csharpSystem.Windows.Interop.D3DImage#1]
Hosting the Direct3D9 Content
Finally, use the xref:System.Windows.Interop.D3DImage class to host the Direct3D9 content.
To host the Direct3D9 content
-
In MainWindow.xaml, replace the automatically generated XAML with the following XAML.
[!code-xamlSystem.Windows.Interop.D3DImage#10]
-
Build the project.
-
Copy the DLL that contains the Direct3D9 content to the bin/Debug folder.
-
Press F5 to run the project.
The Direct3D9 content appears within the WPF application.