简体   繁体   English

使WPF中的WebBrowser控件为只读?

[英]Making a WebBrowser control in wpf read-only?

I would like to make the wpf webbroswer control read-only in the sense that I still want to be able to give users the ability to copy texts off of textfield etc but I dont want them to be ableto click button or submit forms. 我想将wpf webbroswer控件设为只读,因为我仍然希望能够为用户提供从文本字段等复制文本的功能,但我不希望他们能够单击按钮或提交表单。 I wrapped the web browser control in a wpf user control. 我将Web浏览器控件包装在wpf用户控件中。 When I set the IsEnabled proerty to false, it works ie the webbroswer control is disabled but the user cannot select text from the page... 当我将IsEnabled属性设置为false时,它可以工作,即禁用了webbroswer控件,但用户无法从页面中选择文本...

You can handle the WebBrowser's Navigating event and cancel it so that the user can't navigate to another page. 您可以处理WebBrowser的“ 导航”事件并取消它,以使用户无法导航到另一个页面。

void myBrowser_Navigating(object sender, NavigatingCancelEventArgs e)
{
    e.Cancel = true;      
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM