どのように私はC#のコードでボタンのクリックをキャッチすることができますか?
C#コードでボタンをクリックすることができません。
WebView
のScriptNotify
イベントを追加できるようになります。ページがwindow.external.notifyを呼び出し、文字列パラメータを渡すと、ホストされたHTMLページがWindowsストアアプリケーションのScriptNotify
イベントを発生させる可能性があります。例えば
:背後
<WebView x:Name="WebViewControl" ScriptNotify="WebViewControl_ScriptNotify" Source="ms-appx-web:///scriptNotify_example.html"/>
コード:
void WebViewControl_ScriptNotify(object sender, NotifyEventArgs e)
{
// Be sure to verify the source of the message when performing actions with the data.
// As webview can be navigated, you need to check that the message is coming from a page/code
// that you trust.
Debug.WriteLine(e.Value);
}
scriptNotify_example.htmlコード:
<!DOCTYPE html>
<html>
<body>
<p>This is a simple test page for window.external.notify().</p>
<input id="payload" type="text" value="Payload string" />
<button onclick="window.external.notify(payload.value)">Call window.external.notify</button>
<p />
</body>
</html>
これは私がHTMLで行う必要がある変更右? –
私はアプリを書くために勝利jsを使用すると助けになるのだろうか? –
@AravindBelagaje私たちはhtmlを変更できるはずです。 WinJSでも使用できます。 –