-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComboBoxEx.vb
More file actions
65 lines (48 loc) · 1.96 KB
/
ComboBoxEx.vb
File metadata and controls
65 lines (48 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Imports System.Text.RegularExpressions
Imports System.Windows.Controls.Primitives
Imports SharpVectors.Converters
''' <summary>
''' A custom ComboBox that limits the amount of text that can be entered to 7 characters that are Capital letters.
''' </summary>
Public Class ComboBoxEx
Inherits System.Windows.Controls.ComboBox
Public Shared TextBoxProperty As DependencyProperty = DependencyProperty.RegisterAttached("TextBox", GetType(TextBox), GetType(ComboBoxEx))
Public Property TextBox As TextBox
Get
Return CType(GetValue(TextBoxProperty), TextBox)
End Get
Set(value As TextBox)
SetValue(TextBoxProperty, value)
End Set
End Property
Public Shared PopupProperty As DependencyProperty = DependencyProperty.RegisterAttached("Popup", GetType(Popup), GetType(ComboBoxEx))
Public Property Popup As Popup
Get
Return CType(GetValue(PopupProperty), Popup)
End Get
Set(value As Popup)
SetValue(PopupProperty, value)
End Set
End Property
Private Shared ReadOnly regex As New Regex("^[A-Z]+$", RegexOptions.Singleline)
Public Sub New()
MyBase.New
End Sub
Public Overrides Sub OnApplyTemplate()
MyBase.OnApplyTemplate()
TextBox = TryCast(MyBase.GetTemplateChild("PART_EditableTextBox"), TextBox)
If TextBox IsNot Nothing Then
TextBox.VerticalContentAlignment = VerticalAlignment.Center
End If
Popup = TryCast(MyBase.GetTemplateChild("PART_Popup"), Popup)
If Popup IsNot Nothing Then
End If
End Sub
Private Sub tbox_PreviewTextInput(ByVal sender As Object, e As TextCompositionEventArgs)
'If Not regex.IsMatch(e.Text) Then
' e.Handled = True
'End If
End Sub
Private Sub tbox_TextChanged(ByVal sender As Object, e As TextChangedEventArgs)
End Sub
End Class