WPF-WebBrower控件由于某些原因未显示 [英] WPF - The WebBrower Control does not show up for some reason
本文介绍了WPF-WebBrower控件由于某些原因未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在WPF项目中,我将WebBrowser控件和一个按钮拖放到MainWindow上.然后,我点击按钮(button_Click).但是,为什么没有显示WebBrowser控件,为什么?任何人都知道
On a WPF project, I drag and drop a WebBrowser control and a button on the MainWindow. Then, I click on the button (button_Click). However, the WebBrowser control doesn't show up, why? Anyone knows about this
私有void button_Click(对象发送者,RoutedEventArgs e)
{
private void button_Click(object sender, RoutedEventArgs e)
{
WebBrowser浏览器=新的WebBrowser();
browser.Navigate(new Uri(" http://www.bing.com ")))
WebBrowser browser = new WebBrowser();
browser.Navigate(new Uri("http://www.bing.com"));
}
}
推荐答案
您已经在XAML中拥有一个WebBrowser(至少就是您所说的).您正在使用代码创建新的WebBrowser,而不使用现有的WebBrowser.然后,您还没有将新的WebBrowser连接到窗口. 一个或另一个.
You already have a WebBrowser (at least that is what you have said) in the XAML. You are creating a new WebBrowser in code not using the already existing one. Then you have not connected the new WebBrowser to the window. One or the other.
这篇关于WPF-WebBrower控件由于某些原因未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文