本文介绍了我如何禁用WPF WebBrowser控件的点击声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的小WPF应用程序有一个文本框和WebBrowser控件。当我输入到文本框的web浏览器更新其内容。

不过每个按键,当web浏览器的更新,它使一个点击的声音。如何禁用WebBrowser控件的刷新点击声音?

我的XAML ...

 <文本框名称=MyTextBox
         ...
         框TextChanged =MyTextBox_TextChanged
         TextWrapping =自动换行
         AcceptsReturn =真
         VerticalScrollBarVisibility =可见/>
< web浏览器名称=MyWebBrowser... />
 

我的Visual Basic code ...

私人小组MyTextBox_TextChanged(BYVAL发件人为System.Object的,BYVAL E上System.Windows.Controls.TextChangedEventArgs)
    如果没有MyTextBox.Text =的String.Empty然后
        MyWebBrowser.NavigateToString(MyTextBox.Text)
    其他
        MyWebBrowser.Source =无
    结束如果
结束小组

解决方案

该点击becouse导航的,这样做,没有它不应该出现。

我会介绍我的div标签在网页浏览器和更新我会介绍一下文本框的文本在DIV的innerHTML属性的那一刻加载一个空的HTML。没有导航。

Visual Basic中code ...

私人小组Window1_Loaded(BYVAL发件人为System.Object的,BYVAL E上System.Windows.RoutedEventArgs)处理MyBase.Loaded
    MyWebBrowser.NavigateToString(< HTML><身体GT;< D​​IV ID ="" MyDiv"">< / DIV>< / BODY>< HTML>中)
结束小组

私人小组MyTextBox_TextChanged(BYVAL发件人为System.Object的,BYVAL E上System.Windows.Controls.TextChangedEventArgs)
    MyWebBrowser.Document.GetElementById(MyDiv)。innerHTML的= MyTextBox.Text
结束小组

I've got a simple little WPF app with a TextBox and a WebBrowser control. As I type into the TextBox the WebBrowser updates with its content.

But on each keystroke, when the WebBrowser updates, it makes a click sound. How can I disable the WebBrowser control's refresh click sound?

My XAML...

<TextBox Name="MyTextBox"
         ...
         TextChanged="MyTextBox_TextChanged"
         TextWrapping="Wrap"
         AcceptsReturn="True"
         VerticalScrollBarVisibility="Visible" />
<WebBrowser Name="MyWebBrowser" ... />

My Visual Basic code...

Private Sub MyTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.TextChangedEventArgs)
    If Not MyTextBox.Text = String.Empty Then
        MyWebBrowser.NavigateToString(MyTextBox.Text)
    Else
        MyWebBrowser.Source = Nothing
    End If
End Sub
解决方案

That click is becouse of the navigation, doing that without it should not appear.

I would introduce a div tag of mine in an empty HTML loaded in the webbrowser and in the moment of updating I would introduce the text of the textbox in the innerHTML property of the div. Without navigation.

Visual Basic code...

Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
    MyWebBrowser.NavigateToString("<html><body><div id=""MyDiv""></div></body><html>")
End Sub

Private Sub MyTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.TextChangedEventArgs)
    MyWebBrowser.Document.GetElementById("MyDiv").InnerHtml = MyTextBox.Text
End Sub

这篇关于我如何禁用WPF WebBrowser控件的点击声音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 15:10