locked
Could I mix JS/HTML and XAML component together?

    Question

  • Just learning experimenting with WinRT..
     
    I can see you can mix and match C++ and C# WinRT components, they feel like being in the "same realm"..
     
    But how do I mix with Javascript/HTML component?
     
    Say I have a normal DirectX C++ WinRT app, with some AI in C# and I want to show some information text panel with lots of interactive rich text, a job for Javascript.
    How do I show the Javascript/HTML in my XAML app?
    Further, ideally, I'd like to use some of my 'business data' to customize the text / HTML, any sample?

    Sunday, August 26, 2012 5:01 AM

Answers

  • To share your C# library, you can just compile it as a WinRT component.

    You cannot mix javascript and c++, you can however mix directx and xmal using c++. Xmal will provide you the same capabilities as HTML controls. There some example which I've seen that does this, you can probably do a search for them.

    You can also use html5 canvas to handle the drawing instead of directx, if canvas can handle your graphics requirement.

    • Marked as answer by Lloyd Sunday, August 26, 2012 11:16 PM
    Sunday, August 26, 2012 10:34 PM

All replies

  • To share your C# library, you can just compile it as a WinRT component.

    You cannot mix javascript and c++, you can however mix directx and xmal using c++. Xmal will provide you the same capabilities as HTML controls. There some example which I've seen that does this, you can probably do a search for them.

    You can also use html5 canvas to handle the drawing instead of directx, if canvas can handle your graphics requirement.

    • Marked as answer by Lloyd Sunday, August 26, 2012 11:16 PM
    Sunday, August 26, 2012 10:34 PM
  • In fact it was a learning exercise.. I though I could write a little game and put some html help panel... (I am not very fond of HTML dev but want to give it a try)

    but it looks like I will have to come up with an idea to test HTML all on its own... :/

    that said good to know, and I have to investigate, how to do easy rich text with XAML/WinRT?!?

    I mean you could do it with WPF/FlowDocument but that was a hassle compare to HTML/js...

    Sunday, August 26, 2012 11:16 PM
  • You can write WinRT components in C#, VB, or C++ and use them from JavaScript, so mixing non-UI C++ and JavaScript is just fine. A good example of this is the XInput and JavaScript controller sample, which uses a WinRT component written in C++ to access the XInput APIs of DirectX. The XAudio APIs of DirectX can also be used this way from a JavaScript app.

    The short of it is that while you cannot share a drawing surface between HTML/CSS and Direct2D/Direct3D/XAML, other APIs are just fine.

    .Kraig

    Monday, August 27, 2012 3:02 AM