• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 631
  • Last Modified:

WPF Boolean Attached Properties and the property changed callback


namespace AttachedProperties
   public class MyNominalObject :DependencyObject
       public static readonly DependencyProperty UseMouseLeaveProperty =
           DependencyProperty.RegisterAttached("UseMouseLeave", typeof (Boolean), typeof (MyNominalObject), new PropertyMetadata(OnUsingMouseLeave));

       private static void OnUsingMouseLeave(DependencyObject d, DependencyPropertyChangedEventArgs e)
           var result = d.GetValue(UseMouseLeaveProperty);

        public static void SetUseMouseLeave(UIElement element, bool value)
           element.SetValue(UseMouseLeaveProperty, value);

       public static bool GetUseMouseLeave(UIElement element)
           return (bool) element.GetValue(UseMouseLeaveProperty);

       <ListBox local:MyNominalObject.UseMouseLeave="True">
                <ListBoxItem Content="1" />

Why is a breakpoint hit on " var result = d.GetValue(UseMouseLeaveProperty); " when the xaml is local:MyNominalObject.UseMouseLeave="True",

but the breakpoint is not hit it the xaml is:
1 Solution
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now