Sometimes, webpage loaded inside the webview and vice versa needs to communicate or share some object with each other. To do this, you can implement a winrt object that implements IAgileObject and send it to the webview using AddWebAllowedObject method. A new metadata attribute AllowForWeb should be specified above the class which object will be projected. This provides a security option to filter context which can be exposed to the webpage loaded inside webview.

Under the Output heading below, the displayed HTML has been loaded into the WebView control. The Winrt object is a simple prime number calculator. Enter a valid range below and then tap the "Reload" button. The webview page notifies the app whenever it finds a new prime number in the range. The WinRT object will stop calculating when it reaches the end of the range or when the app sets the cancel property in the event handler.

Cancel after next prime is generated