I recently added a new dependency property to a control of mine and bound its value to my control's ViewModel. I put custom code in the Get method of the dependency property and saw the return value from that method does not come across to the ViewModel.
After some research, it seems that when the XAML parser attempts to get or set this property's value that it does not use these get/set methods at all. So to make this DP useful for my scenario, I have to figure out another way to set this value
ahead of time, i.e. through code.
My question is, what is the point of these get/set methods for your DP if the XAML parser isn't going to use them? Is it really all that useful to use these in code? I would imagine DP's are mostly being used for the purpose of data binding in
which case it'd be helpful to be able to define how WPF will get and set the value. I liken this scenario to a public property with a private backing field, and having WinForms or whatever just directly access the backing field and skipping my property's
getter/setter, which would obviously be a bug.
I'd appreciate any insight on this.
View Complete Post