Expose Textbox Members for AutoCompleteBox

Aug 23, 2010 at 2:59 PM

I started using the AutoCompleteBox and noticed that the underlying Textbox Members are missing.  This really hurts the functionality of the control.  I created my own class that inherits from Toolkit AutoCompleteBox to expose the members, but I thought it would be useful to see this in the next release of the toolkit.  It's not comprehensive (I've only added the members I needed at the time), but you'll get the idea:

 

Public Class AutoCompleteBoxEnhanced
    Inherits AutoCompleteBox

    Private _TextBox As TextBox

    Public Overrides Sub OnApplyTemplate()
        MyBase.OnApplyTemplate()

        _TextBox = GetTemplateChild("Text")

    End Sub

    Public Property SelectionStart As Integer
        Get
            Return _TextBox.SelectionStart
        End Get
        Set(ByVal value As Integer)
            _TextBox.SelectionStart = value
        End Set
    End Property

    Public Sub SelectAll()
        _TextBox.SelectAll()
    End Sub

    Public Property SelectedText As String
        Get
            Return _TextBox.SelectedText
        End Get
        Set(ByVal value As String)
            _TextBox.SelectedText = value
        End Set
    End Property

    Public Sub FocusText()
        _TextBox.Focus()
    End Sub