title: Silverlight textbox overrides
body: <p>I'm trying to get a textbox keydown event to trap the backspace key down event.  I have that working by adding a Class that overrides the textbox.   What i don't know how to do is have that communicate with the class where the textbox is in the user control.</p>
  
  <p>When a user types in the text box... say abcd or backspace, i need to update something on the usercontrol.  let's just say i want to have something that displays how many characters are in the textbox.  can someone help me with that.  Here is what i have so far</p>
  
  <pre><code>Option Strict On
  Imports System.Text.RegularExpressions
  
  Partial Public Class Page
      Inherits UserControl
  
      Public Sub New()
          InitializeComponent()
          Dim textbox As New MyTextBox() With {.Width = 300, .Height = 100}
          LayoutRoot.Children.Add(textbox)
      End Sub
  End Class
  
  Public Class MyTextBox
      Inherits TextBox
      Protected Overrides Sub OnKeyDown(ByVal e As KeyEventArgs)
          MyBase.OnKeyDown(e)
          If e.Key = Key.Back Then
              e.Handled = True
              MyBase.OnKeyDown(e)
  
          ElseIf e.Key = Key.Delete Then
              e.Handled = True
              MyBase.OnKeyDown(e)
          End If
      End Sub
  End Class
  </code></pre>
  
  <p>thanks
  shannon</p>