Use DirectWrite from a C# XAML Metro-style app

2

Could you provide some guidelines for how to use DirectWrite from a C# XAML-based Metro-style app. I want to create a XAML-based UI, but I also want to write custom text onto the screen effectively.

My guess is that I can create a WinRT component in C++ which access DirectWrite directly, and use that component from the C# project. Is that possible?

I tried to reference a Direct2D project from a C# XAML Metro application, but I couldn't even instantiate the class generated by the Direct2D template (it threw "A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)" exception).

Then I tried to create a WinRT Component DLL project, and then copy paste the code files from the Direct2D project to that, but I wasn't able to get it compile.

Are there fundamental differences between the Direct2D and the WinRT Component DLL project types? Can I access the classes from C# created in the earlier? Can I use Direct2D from the latter?

UPDATE: I found a - somewhat disappointing - answer to a similar question (http://social.msdn.microsoft.com/Forums/en-ZA/winappswithcsharp/thread/2d7ab4a7-9248-426e-8b4d-644b451bef7a), but that was before the Consumer Preview. I hope the situation has changed since then.

c#
c++
xaml
windows-runtime
directx
asked on Stack Overflow Mar 8, 2012 by Mark Vincze • edited Mar 24, 2015 by CCovey

2 Answers

2

It's a very late answer, but... This DirectX C++/CX wrapper: http://directxwinrt.codeplex.com/ Expose quite a good chunk of D2D (but little of DWrite, ...)

answered on Stack Overflow Feb 17, 2013 by Lloyd Dupont
0

Now I found a blog post which answers the part of my question whether this is possible: http://blogs.msdn.com/b/windowsappdev/archive/2012/03/01/what-s-changed-since-build-part-1.aspx, so it is possible to mix XAML and DirectX since the Consumer Preview.

Here is a detailed guide how to do that: http://msdn.microsoft.com/library/windows/apps/hh825871.aspx. I am going to update this answer if I find out what was wrong with my approach, and how should it properly be done.

answered on Stack Overflow Mar 9, 2012 by Mark Vincze

User contributions licensed under CC BY-SA 3.0