Imports System.Windows.Controls.Primitives


Public Class TextBox2nd
    Inherits System.Windows.Controls.TextBox

    Shared Sub New()
        'この OverrideMetadata 呼び出しは、この要素が基本クラスと異なるスタイルを提供することをシステムに通知します。
        'このスタイルは themes\generic.xaml に定義されています
        DefaultStyleKeyProperty.OverrideMetadata(GetType(TextBox2nd), New FrameworkPropertyMetadata(GetType(TextBox)))
    End Sub

    Public Shared ReadOnly DateValueProperty As DependencyProperty = DependencyProperty.Register( _
          "DateValue", _
          GetType(Date?), _
          GetType(TextBox2nd), _
          New PropertyMetadata())

    Public Property DateValue() As Date?
        Get
            Return DirectCast(GetValue(DateValueProperty), Date)
        End Get
        Set(ByVal value As Date?)
            SetValue(DateValueProperty, value)

            'このタイミングでTextプロパティに設定した日付を表示したい
            SetValue(TextProperty, value.ToString)

        End Set
    End Property

End Class