Files
docs-desktop/dotnet-desktop-guide/framework/wpf/advanced/walkthrough-hosting-direct3d9-content-in-wpf.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* 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
2020-09-04 09:46:28 -07:00

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
Direct3D9 [WPF interoperability], hosting Direct3D9 content
WPF [WPF], hosting Direct3D9 content
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:

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:

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

  1. Open MainWindow.xaml.cs in the Code Editor.

  2. 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

  1. In MainWindow.xaml, replace the automatically generated XAML with the following XAML.

    [!code-xamlSystem.Windows.Interop.D3DImage#10]

  2. Build the project.

  3. Copy the DLL that contains the Direct3D9 content to the bin/Debug folder.

  4. Press F5 to run the project.

    The Direct3D9 content appears within the WPF application.

See also