C++, C# and JavaScript on Winrt

How to execute Javascript code in a WinRT C# application?

It's possible to call JavaScript from C# but not without a WebView control.

Can XAML be used with JavaScript in WinRT?

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.

Passing a JS callback function to C# RT Component error: Unable to cast object of the type 'mydb.SQLite3JSNoCallback' to 'mydb.SQLite3JSNoCallback'

When I removed the IASyncOperation from the function, the js callback worked without issue.

There seems to be a problem because I am having a blocking callback function sent as the parameter, I believe. Can any one clarify how it can work with IASyncOperation present in my function.

Should I send in an ASyncCallback function to the C# RT Component to be able to get a callback.

Still the answer remains for the above problem to make the RT Component's function a blocking function if you need a javascript callback to successfully work,

Regards,

Jay

Pass javascript object to winrt component written in C#

I think this is your answer.

var ps = new Windows.Foundation.Collections.PropertySet();
ps['aaa'] = "bbb";

var x = new MyNamespace.MyClass();
x.MyFunction(ps);

"Your WinRT component will need to expose (or reuse) a concrete class implementing the specific instantiation of IMap that you need..."

WinRT WinJS + C#

Yes, you need to repackage them. Create a Windows Runtime Component project from file-new project (and not the class library type). When you compile you'll see what you need to fix as there are some restrictions on types.

Classes need to be sealed, can't inherit (except in limited cases) and other restrictions. This project type creates the .winmd (metadata) that can be used by your JavaScript app.

The important note is from here: .NET Framework Support for Windows Store Apps and Windows Runtime

If your component will be used only with C# or Visual Basic, there's no reason to make it a Windows Runtime component. If you make it an ordinary .NET Framework class library instead, you don't have to restrict its public API surface to Windows Runtime types.

Win8 Javascript Metro App, with C# WinRT Component and SQLite

I found the solution. I used the hint from this post, and it's very straightforward.

What I have to do, is to create another project in the solution, with Output Type set to C# Class Library. Move the reference to SQLite for WinRT, and sqlite-net (nuget) wrapper to this new project. After that, I have to manually go through classes in sqlite-net, and change all the 'internal' classes to 'public'.

For the original controller project, I add using myclasslib; so that class definitions are found.

Apparently this workaround will work flawlessly. SQLite3 is deployed, and there's no warning against missing reference.



Related Topics



Leave a reply



Submit