Suppose I'm writing a WinRT app with both JavaScript and C# code, and I want my JavaScript code to hook an event on my C# object.
I know that's supposed to be possible, but what would that JavaScript code look like? How are events (however the concept of a CLR event is represented in WinRT) exposed in the JavaScript projection?
If a concrete example would help, let's say my C# object has this event:
public event EventHandler Initialized;
How do I hook that event from JavaScript?
(I'm sure the answer is buried in one of the //build/ videos, but they're not exactly searchable.)
Once you have your C# class hooked up and accessible from JavaScript (see C# //Build/ talk for details), it should be as simple as this:
var foo = new CSharpClass();
foo.addEventListener("Initialized", onInitialized);
Then when C# fires the event, your onInitialized function will be called.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With