Solved

WPF Boolean Attached Properties and the property changed callback

Posted on 2014-01-12
1
566 Views
Last Modified: 2014-01-12
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",
0
Comment
Question by:quentinA
1 Comment
 

Accepted Solution

by:
quentinA earned 0 total points
ID: 39774704
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video discusses moving either the default database or any database to a new volume.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now