4

I added references to WinRT dlls to a WPF project and I want to use SwapChainPanel inside of a WPF window. Is it really possible? For now I cant get it work.

Filip Skakun
  • 31,624
  • 6
  • 74
  • 100
Denis
  • 334
  • 4
  • 17

3 Answers3

1

The NuGet package description for Microsoft.Toolkit.Wpf.UI.Controls mentions a SwapChainPanel but I have not found any samples using this control in WPF.

SwapChainPanel : Provides a hosting surface, where Microsoft DirectX swap chains provide content that can be rendered into a XAML UI. A SwapChainPanel element is a key component for an app that renders Microsoft DirectX graphics and then presents those visuals within a XAML page.

Magnus Lindhe
  • 7,157
  • 5
  • 48
  • 60
0

It's not currently officially supported - might require some private APIs in Windows, though since Stardock could implement its ModernMix - there might be some way to get it working. The thing is though - you don't have to do that. You can render content with DirectX to a WPF window in other ways. I haven't done that and it might be quite a bit of work to do, but so is anything in DirectX. You can look into DirectComposition or D3DImage class. Perhaps the article on using Direct2D with WPF can be a good sample solution.

Filip Skakun
  • 31,624
  • 6
  • 74
  • 100
0

You dont have to, as says Filip Skakun, but you can ! Just give a try to SlimDX or SharpDX. They're DirectX's implementations in C#.

kiwixz
  • 1,380
  • 15
  • 23
  • I don't think SlimDX or SharpDX allow you to put a WinRT `SwapChainPanel` control into a WPF app. They are C# wrappers for DirectX and while they might have helper classes or controls that are easy to host in window - that's not what the question was exactly about. Also there's another managed wrapper for DirectX 10-11 that I helped build a while back called [Windows API Code](http://archive.msdn.microsoft.com/WindowsAPICodePack) that is used in that Direct2D article. I'm not sure how long it will be available though since the code gallery page is being retired... tomorrow? :) – Filip Skakun May 14 '14 at 22:13
  • This is the best way I know. There is a SwapChain. – kiwixz May 15 '14 at 05:10