NotifyEventHandler 代理人

定義

表示將處理 ScriptNotify 事件的方法。

public delegate void NotifyEventHandler(Platform::Object ^ sender, NotifyEventArgs ^ e);
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Guid(3271414264, 28933, 19060, 161, 9, 222, 41, 223, 245, 107, 152)]
class NotifyEventHandler : MulticastDelegate
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Guid(3271414264, 28933, 19060, 161, 9, 222, 41, 223, 245, 107, 152)]
public delegate void NotifyEventHandler(object sender, NotifyEventArgs e);
Public Delegate Sub NotifyEventHandler(sender As Object, e As NotifyEventArgs)

參數

sender
Object

Platform::Object

IInspectable

附加處理常式的物件。

e
NotifyEventArgs

事件的事件資料。

屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

下列程式碼範例示範如何在針對 Windows 8 編譯的應用程式中使用 ScriptNotify 事件。 從 Windows 8.1 開始,請省略與 AllowedScriptNotifyUris相關的行。 如需詳細資訊,請參閱 WebView 類別概觀。

public MyPage()
{
    this.InitializeComponent();
    MyWebView.ScriptNotify += MyWebView_ScriptNotify;

    // Here we have to set the AllowedScriptNotifyUri property because we are 
    // navigating to some site where we don't own the content and we want to 
    // allow window.external.notify() to pass data back to the app.
    List<Uri> allowedUris = new List<Uri>();
    allowedUris.Add(new Uri("http://www.bing.com"));
    MyWebView.AllowedScriptNotifyUris = allowedUris;
}

void MyWebView_ScriptNotify(object sender, NotifyEventArgs e)
{
    // Respond to the script notification.
}

適用於