Я создал класс объекта зависимостей:
Public Class TextMonitoring
Inherits DependencyObject
Public Shared ReadOnly MonitorTextProperty As DependencyProperty = DependencyProperty.RegisterAttached("MonitorText",
GetType(Boolean),
GetType(TextMonitoring),
New PropertyMetadata(False, New PropertyChangedCallback(AddressOf MonitorTextChanged)))
Public Shared Function GetMonitorTextProperty(sender As DependencyObject) As Boolean
Return CType(sender, PasswordBox).GetValue(MonitorTextProperty)
End Function
Public Shared Sub SetMonitorTextProperty(sender As DependencyObject)
CType(sender, PasswordBox).SetValue(MonitorTextProperty, True)
End Sub
Public Shared Function GetMonitorText(sender As DependencyObject) As Boolean
Return CType(sender, PasswordBox).GetValue(MonitorTextProperty)
End Function
Public Shared Sub SetMonitorText(sender As DependencyObject)
CType(sender, PasswordBox).SetValue(MonitorTextProperty, True)
End Sub
Public Shared Sub MonitorTextChanged(sender As DependencyObject, e As DependencyPropertyChangedEventArgs)
End Sub
Конечный класс
Мой стиль содержит установщик:
xmlns:local="clr-namespace:TestAttachedProperty">
<Style TargetType="{x:Type PasswordBox}">
<Setter Property="FontSize" Value="24" />
<Setter Property="Padding" Value="10" />
<Setter Property="Margin" Value="0 5 0 5" />
<Setter Property="local:TextMonitoring.MonitorText" Value="True" />
Компиляция выдает ошибку: XDG0013: Свойство «MonitorText» не имеет доступного установщика.
Что я делаю не так?