R – How to disable the WPF WebBrowser control’s click noise

browsernetwpf

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?

WPF TextBox and WebBrowser controls http://img411.imageshack.us/img411/2296/appbz9.jpg

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

Best Answer

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("&lt;html&gt;&lt;body&gt;&lt;div id=&quot;&quot;MyDiv&quot;&quot;&gt;&lt;/div&gt;&lt;/body&gt;&lt;html&gt;")
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