WebBrowser
WebBrowser - 显示一个简单的字符串消息,无需导航(WebBrowser - show a simple string message without navigating away)我有一个WebBrowser(System.Windows.Controls.WebBrowser),它在特定时间打开并且什么都不显示。 它只是白页。 我希望在该表单中显示一条简单的消息“Waiting”,而不会在其他地方重定向。 此WebBrowser是WPF xaml表单的一部分。
我曾尝试在下面的WebBrowser_Loaded事件中执行此操作,但再次调用OnNavigate(),这是我不想做的事情。 我只需要在其中获得简单的字符串消息,例如“Waiting”,就是这样。
private void WebBrowser_Loaded(object sender, EventArgs e){ ((WebBrowser)sender).NavigateToString("<html><body><h1>Waiting</h1></body></html>"); // this will try to navigate to new page which is what I do not want to do}I have a WebBrowser (System.Windows.Controls.WebBrowser) that opens at certain time and displays nothing. It is just white page. I'd like to display a simple message "Waiting" in that form without redirecting anywhere else. This WebBrowser is part of a WPF xaml form.
I have tried to do this in WebBrowser_Loaded event below but that calls OnNavigate() again which is what I dont want to do. I just need to get simple string message like "Waiting" in it, that is all.
private void WebBrowser_Loaded(object sender, EventArgs e){ ((WebBrowser)sender).NavigateToString("<html><body><h1>Waiting</h1></body></html>"); // this will try to navigate to new page which is what I do not want to do} 最满意答案我发现.NET WebBrowser控件真的很挑剔,有点难以处理。 我建议做这样的事情:
将TextBox或Label控件放在WebBrowser控件的顶部,其中包含“Waiting ...”文本,并在WebBrowser的Navigating(或Navigated)事件中隐藏该控件。
I've found the .NET WebBrowser control to be really finicky and somewhat hard to deal with. I would suggest doing something like this:
Put a TextBox or Label control on top of the WebBrowser control with the "Waiting..." text in it, and hide that control in the Navigating (or Navigated) event for the WebBrowser.