Reputation: 1
Does this idea make any sense? ie to try and learn the inner workings of XAML by analyzing how Moonlight handles XAML code and then see if there might be a way to convert XAML code to Javascript code?
Upvotes: 0
Views: 133
Reputation: 416
I went through a similar exercise several years ago (while I was working on Moonlight, as it happens.) It doesn't so much convert XAML to javascript, but embeds XAML into the html dom and then uses javascript in place of C#.
Check out https://github.com/toshok/firelight. I added some WPF-isms as well, since WPF has a much saner implementation of the DependencyObject/DependencyProperty stuff.
Unsure if it works in modern browsers.
There are a couple of simple demos in that repo:
https://github.com/toshok/firelight/blob/master/firelight/node.xhtml has xaml: namespaced nodes at the end of the file.
https://github.com/toshok/firelight/blob/master/firelight/code.xhtml builds a trivial scene using nothing but JS.
update
- I checked things on chrome and safari (OSX), and code.xhtml seems to work on both. node.xhtml has some issues, and doesn't work in either. One further test, complete with bitmap effects, triggers, setters, animations, events, and Britney Spears, is https://github.com/toshok/firelight/blob/master/firelight/xaml.xhtml.
Upvotes: 4