Read-only attached property in trigger (WPF)
I don't know if there is something special with your read-only attached property, but if you declare it in default manner it works:
public class AttachedPropertyHelper : DependencyObject{ public static int GetSomething(DependencyObject obj) { return (int)obj.GetValue(SomethingProperty); } public static void SetSomething(DependencyObject obj, int value) { obj.SetValue(SomethingProperty, value); } // Using a DependencyProperty as the backing store for Something. This enables animation, styling, binding, etc... public static readonly DependencyProperty SomethingProperty = DependencyProperty.RegisterAttached("Something", typeof(int), typeof(AttachedPropertyHelper), new UIPropertyMetadata(0));}
EDIT
If you want the same as a readonly attached property you change it to:
public class AttachedPropertyHelper : DependencyObject{ public static int GetSomething(DependencyObject obj) { return (int)obj.GetValue(SomethingProperty); } internal static void SetSomething(DependencyObject obj, int value) { obj.SetValue(SomethingPropertyKey, value); } private static readonly DependencyPropertyKey SomethingPropertyKey = DependencyProperty.RegisterAttachedReadOnly("Something", typeof(int), typeof(AttachedPropertyHelper), new UIPropertyMetadata(0)); public static readonly DependencyProperty SomethingProperty = SomethingPropertyKey.DependencyProperty;}