短い日付 (例: "010111"、"01012011"、または "01-01-2011") を入力できるようにカスタムの日付ピッカー コントロールを作成しましたが、
どういうわけかイベントがトリガーされません。
Public Class DatePicker
Inherits System.Windows.Controls.DatePicker
Private Sub DatePicker_PreviewTextInput(sender As Object, e As Windows.Input.TextCompositionEventArgs) Handles Me.PreviewTextInput
If Me.Text.Length >= 6 Then
Dim strInput As String = Me.Text.Trim
Dim dtInput As Date = Nothing
Select Case strInput.Length
Case Is = 6
dtInput = New Date(CInt(Mid(strInput, 5, 2)), CInt(Mid(strInput, 3, 2)), CInt(Mid(strInput, 1, 2)))
Case Is = 8
dtInput = New Date(CInt(Mid(strInput, 5, 4)), CInt(Mid(strInput, 3, 2)), CInt(Mid(strInput, 1, 2)))
Case Is >= 10
dtInput = New Date(CInt(Mid(strInput, 7, 4)), CInt(Mid(strInput, 4, 2)), CInt(Mid(strInput, 1, 2)))
End Select
Me.SelectedDate = dtInput
End If
e.Handled = True
End Sub
End Class