Search code examples
c#xamlwindows-runtimedirect2dsharpdx

Using Direct2D from Xaml and C# (using SharpDX)


This question is about the Direct2D / XAML interop helpers ISurfaceImageSource and IVirtualSurfaceImageSource.

The samples I've seen about these two helpers, such as this one, are in C++.

Question: I'd like to render to these in C# using SharpDX. How can I do so?

(It is OK if there is a little C++ just at the API boundary - C# cannot consume the Direct2D interfaces directly.)

Note: I already understand the other XAML interop helpers like SwapChainPanel, so please provide answers relating to ISurfaceImageSource and IVirtualSurfaceImageSource only.


Solution

  • I found that the SharpDX samples include a ported C#/SharpDX version of this C++ Windows SDK sample that shows exactly how to do this. Great.