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(New PropertyChangedCallback(AddressOf OnDateChanged)))
Public Property DateValue() As Date?
Get
Return DirectCast(GetValue(DateValueProperty), Date?)
End Get
Set(ByVal value As Date?)
SetValue(DateValueProperty, value)
End Set
End Property
Private Shared Sub OnDateChanged(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
Dim textbox2 As TextBox2nd = DirectCast(d, TextBox2nd)
If DirectCast(e.NewValue, Date?).HasValue Then
textbox2.SetValue(TextProperty, DirectCast(e.NewValue, Date?).Value.ToString("yyyy/MM"))
Else
textbox2.SetValue(TextProperty, String.Empty)
End If
End Sub
End Class
SW1wb3J0cyBTeXN0ZW0uV2luZG93cy5Db250cm9scy5QcmltaXRpdmVzCgoKUHVibGljIENsYXNzIFRleHRCb3gybmQKICAgIEluaGVyaXRzIFN5c3RlbS5XaW5kb3dzLkNvbnRyb2xzLlRleHRCb3gKCiAgICBTaGFyZWQgU3ViIE5ldygpCiAgICAgICAgJ+OBk+OBriBPdmVycmlkZU1ldGFkYXRhIOWRvOOBs+WHuuOBl+OBr+OAgeOBk+OBruimgee0oOOBjOWfuuacrOOCr+ODqeOCueOBqOeVsOOBquOCi+OCueOCv+OCpOODq+OCkuaPkOS+m+OBmeOCi+OBk+OBqOOCkuOCt+OCueODhuODoOOBq+mAmuefpeOBl+OBvuOBmeOAggogICAgICAgICfjgZPjga7jgrnjgr/jgqTjg6vjga8gdGhlbWVzXGdlbmVyaWMueGFtbCDjgavlrpr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