我有一个只读的附加属性问题。 我是这样定义它的:
public class AttachedPropertyHelper : DependencyObject
{
public static readonly DependencyPropertyKey SomethingPropertyKey = DependencyProperty.RegisterAttachedReadOnly("Something", typeof(int), typeof(AttachedPropertyHelper), new PropertyMetadata(0));
public static readonly DependencyProperty SomethingProperty = SomethingPropertyKey.DependencyProperty;
}
我希望在XAML中使用它:
<Trigger Property="m:AttachedPropertyHelper.Something" Value="0">
<Setter Property="FontSize" Value="20"/>
</Trigger>
但是编译器不想使用它。
结果出现了2个错误:
在类型 'ReadonlyAttachedProperty.AttachedPropertyHelper' 上找不到样式属性'Something'。行11位置16。
'TextBlock'类型中未找到属性'Something'。