【发布时间】:2012-05-18 08:07:31
【问题描述】:
我对只读附加属性有疑问。 我是这样定义的:
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”中找不到属性“某物”。
【问题讨论】:
标签: c# wpf triggers readonly attached-properties