An example of how to drag an item from XAML to WebView. This is not a complete solution, but may be useful to you.
XAML:
<StackPanel Orientation="Vertical" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<WebView DefaultBackgroundColor="LightGray" Source="ms-appx-web:///HTMLPage1.html" PointerReleased="WebViewElm_PointerReleased" Width="300" Height="300" x:Name="WebViewElm"></WebView>
<TextBlock x:Name="txtZiel" DragOver="txtZiel_DragOver" PointerReleased="txtZiel_PointerReleased" >2</TextBlock>
</StackPanel>
C # code:
private async void WebViewElm_PointerReleased(object sender, PointerRoutedEventArgs e)
{
await WebViewElm.InvokeScriptAsync("callFromExternal", new string[] { txtZiel.Text });
}
private async void WebViewElm_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
{
await WebViewElm.InvokeScriptAsync("LoadingFinished", null);
}
HTML:
<body>
<p id="txtClick">1</p>
</body>
JavaScript:
function callFromExternal(somedrag) {
document.getElementById("txtClick").innerHTML = somedrag;
}
The only thing you need to do is check the mouse over the paragraph element in your JavaScript code.
JavaScript, NavigationCompleted = "WebViewElm_NavigationCompleted" ScriptNotify = "WebViewWithJSInjection_ScriptNotify" WebView #
private async void WebViewElm_NavigationCompleted(WebView sender, WebViewNavigationCompletedEventArgs args)
{
await WebViewElm.InvokeScriptAsync("LoadingFinished", null);
}
private void WebViewWithJSInjection_ScriptNotify(object sender, NotifyEventArgs e)
{
}
JavaScript :
function LoadingFinished()
{
document.getElementById('txtClick').addEventListener("mousedown", callExternal);
}
function callExternal()
{
window.external.notify(document.getElementById("txtClick").innerHTML);
}