fork download
  1. Imports System.Windows.Controls.Primitives
  2.  
  3.  
  4. Public Class TextBox2nd
  5. Inherits System.Windows.Controls.TextBox
  6.  
  7. Shared Sub New()
  8. 'この OverrideMetadata 呼び出しは、この要素が基本クラスと異なるスタイルを提供することをシステムに通知します。
  9. 'このスタイルは themes\generic.xaml に定義されています
  10. DefaultStyleKeyProperty.OverrideMetadata(GetType(TextBox2nd), New FrameworkPropertyMetadata(GetType(TextBox)))
  11. End Sub
  12.  
  13. Public Shared ReadOnly DateValueProperty As DependencyProperty = DependencyProperty.Register( _
  14. "DateValue", _
  15. GetType(Date?), _
  16. GetType(TextBox2nd), _
  17. New PropertyMetadata(New PropertyChangedCallback(AddressOf OnDateChanged)))
  18.  
  19. Public Property DateValue() As Date?
  20. Get
  21. Return DirectCast(GetValue(DateValueProperty), Date?)
  22. End Get
  23. Set(ByVal value As Date?)
  24. SetValue(DateValueProperty, value)
  25.  
  26. End Set
  27. End Property
  28.  
  29. Private Shared Sub OnDateChanged(ByVal d As DependencyObject, ByVal e As DependencyPropertyChangedEventArgs)
  30. Dim textbox2 As TextBox2nd = DirectCast(d, TextBox2nd)
  31. If DirectCast(e.NewValue, Date?).HasValue Then
  32. textbox2.SetValue(TextProperty, DirectCast(e.NewValue, Date?).Value.ToString("yyyy/MM"))
  33. Else
  34. textbox2.SetValue(TextProperty, String.Empty)
  35. End If
  36.  
  37. End Sub
  38.  
  39. End Class
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty