我创建了一个TextBox继承标准 WPF 的 Extended ,TextBox我现在要做的是创建其他扩展控件类型,如 a TextBlock、ListBox等ComboBox。所有控件都将具有相同的 DependencyProperties ,如下所示,所以我试图找到一种方法来实现这无需重复DependencyProperty每个新扩展控件背后的代码。
Public Class ExtendedTextBox
Inherits TextBox
Public Shared MandatoryProperty As DependencyProperty = DependencyProperty.Register("Mandatory", GetType(Boolean), GetType(ExtendedTextBox))
Public Shared ReadOnly HasAnyErrorsProperty As DependencyProperty = DependencyProperty.Register("HasAnyErrors", GetType(Boolean), GetType(ExtendedTextBox))
End Class