Как я могу поймать сообщение в коде Xaml позади (родительское окно)? Моё дочернее окно выдает это сообщение
В дочернем окне
function sendMsg() {
var status = document.getElementById("status");
if (parent && parent.postMessage) {
parent.postMessage("Hello from child window", "*");
status.innerText = "Sent message to parent...";
}
}
В родительском окне (xaml.cs),
private void button1_Click(object sender, RoutedEventArgs e)
{
// Get URI to navigate to
Uri uri = new Uri("child window url to be opened");
// Navigate to the desired URL by calling the .Navigate method
this.mybrowser.Navigate(uri);
}
В Xaml,
<WebBrowser Name="mybrowser" Margin="339,10,10,10" Height="396"></WebBrowser>
<Button Content="Send Message to WebView" Margin="10,-700,736,0" Height="20" Click="Button_Click"/>