Avatar of quentinA
quentinA
Flag for United Kingdom of Great Britain and Northern Ireland asked on

WPF Boolean Attached Properties and the property changed callback

c#:

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);
       }
    }

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


Question:
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:
 local:MyNominalObject.UseMouseLeave="False",
.NET ProgrammingC#Microsoft Development

Avatar of undefined
Last Comment
quentinA

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
quentinA

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes