Solved

WPF Boolean Attached Properties and the property changed callback

Posted on 2014-01-12
1
585 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

839 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