Or JavaScript is only restricted to HTML? I've only seen HTML-JavaScript demos at Build 2011
-
1Why would you wish to do so? If you know javascript then you are lickly to know HTML. (I think of a JavaScript winrt app as being an "of-line" website with the look and feel of Windows 8) – Ian Ringrose Sep 24 '11 at 20:41
-
Because javascript is a great dynamic language. Why should I use HTML for a desktop application when there's much better technology we can use? I don't understand that. – Alice Sep 27 '11 at 19:22
2 Answers
XAML is not supported in JavaScript Metro apps - those classes are specifically hidden from JavaScript WinRT projection.
This actually includes not just the stuff under Windows.UI.Xaml
, but also some other classes elsewhere, usually when they do something that is already covered by JS standard library (with HTML5 extensions). The easiest way to see what exactly is hidden is to inspect WinRT .idl files (in "C:\Program Files (x86)\Windows Kits\8.0\Include\winrt") and search for webhosthidden
. Those interfaces which have [webhosthidden]
attribute applied to them are not visible from JS. Sometimes you'll also see comments explaining why a particular interface is hidden.

- 99,783
- 25
- 219
- 289
Not yet. XAML is used only from C# or C++, and for JavaScript you need HTML5.
One of reasons is that in case of HTML + JavaScript the same engine as in IE10 is used for rendering. (By the way, Metro version of IE10 doesn't support plugins like Silverlight.)
The other currently missing area is that you cannot use ASP.NET / ASP.NET MVC to build metro style applications, which would allow combining C# and HTML.

- 3,576
- 1
- 25
- 41
-
"By the way, IE10 doesn't support plugins like Silverlight." Metro IE10 doesn't support it, regular IE does. – Lukasz Madon Sep 23 '11 at 17:02
-
"It should be possible to use Microsoft's Razor formatting engine to style applications using HTML/CSS while using C#." (But it is not yet.) http://tirania.org/blog/archive/2011/Sep-15.html – Roman Boiko Sep 23 '11 at 21:03
-
It is likely possible to use C# by utilizing one of the available C#-to-JS or MSIL-to-JS translators, but... why? If you want a Metro app with UI in HTML and C# in the backend, just make a C# XAML app with a single fullscreen `WebView` control. – Pavel Minaev Sep 24 '11 at 03:54
-
1@Pavel I'm choosing between HTML and XAML. Looks like HTML wins due to partial ability to reuse HTML5 + JavaScript for Web (outside Windows), but I also like the advantages of C# for domain logic. I was also thinking about implementing a WinRT component in C# and using it from JavaScript. – Roman Boiko Sep 24 '11 at 07:41