我可以在metro ui javascript代码中使用C#中创建的对象吗?
我真的很喜欢C#,我对它很熟悉,但我也想使用HTML5/JavaScript来管理我的Windows8Metro应用程序的UI。那么,如何从Javascript文件中的C#库中导入和使用对象呢 这里的示例是空HTML5/JS项目的启动JS代码我可以在metro ui javascript代码中使用C#中创建的对象吗?,c#,windows-8,microsoft-metro,C#,Windows 8,Microsoft Metro,我真的很喜欢C#,我对它很熟悉,但我也想使用HTML5/JavaScript来管理我的Windows8Metro应用程序的UI。那么,如何从Javascript文件中的C#库中导入和使用对象呢 这里的示例是空HTML5/JS项目的启动JS代码 // For an introduction to the Blank template, see the following documentation: // http://go.microsoft.com/fwlink/?LinkId=232509
// For an introduction to the Blank template, see the following documentation:
// http://go.microsoft.com/fwlink/?LinkId=232509
(function () {
"use strict";
var app = WinJS.Application;
app.onactivated = function (eventObject) {
if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
if (eventObject.detail.previousExecutionState !== Windows.ApplicationModel.Activation.ApplicationExecutionState.terminated) {
// TODO: This application has been newly launched. Initialize
// your application here.
} else {
// TODO: This application has been reactivated from suspension.
// Restore application state here.
}
WinJS.UI.processAll();
}
};
app.oncheckpoint = function (eventObject) {
// TODO: This application is about to be suspended. Save any state
// that needs to persist across suspensions here. You might use the
// WinJS.Application.sessionState object, which is automatically
// saved and restored across suspension. If you need to complete an
// asynchronous operation before your application is suspended, call
// eventObject.setPromise().
};
app.start();
})();
我可以拉入并使用用C#编写的JS中的库和对象吗
他们似乎将C与基于HTML5的项目隔离开来,我有点不高兴…你绝对可以做到这一点。这就是Windows8和新应用程序模型的优点。有很多地方可以开始和看 从这里开始:您可以在上面的链接中进一步深入,其中还链接到一个真正的基本示例 简而言之,您将在C#中创建一个metro类库,然后将C#的输出类型从“类库”设置为WinMD。然后,您可以在javascript项目中引用并使用该库 有很多关于构建metro应用程序的文档可在