空白のテンプレートを使用している場合(コメントに記載されているように)、提案されたデモコードをonactivateイベントに配置すると機能するはずです。以下は、ブラックボックスの左上隅から右下隅に白い線を表示するはずです。
default.html:
<body>
<p>Content goes here</p>
<canvas id="can1" width="500" height="500"></canvas>
</body>
default.jsのapp.onactivateメソッド内:
app.onactivated = function (args) {
if (args.detail.kind === activation.ActivationKind.launch) {
if (args.detail.previousExecutionState !== 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.
}
var myCanvas = document.getElementById("can1");
var myContext = myCanvas.getContext("2d");
myContext.fillStyle = '#000';
myContext.strokeStyle = '#fff';
myContext.fillRect(0, 0, 500, 500);
myContext.lineWidth = 3;
myContext.fill();
myContext.moveTo(0, 0);
myContext.lineTo(500, 500);
myContext.stroke();
args.setPromise(WinJS.UI.processAll());
}
};