Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
You don’t have to define the properties of your WPF classes as dependency properties. Plain Old POCO properties work just fine, but they don’t take advantage of the things that make WPF such a joy to work with. Would you go to a five-star restaurant and only have a glass of water?
It’s really not that difficult to make the magic happen. There are only four steps, and two of them are optional:
1 CREATE THE CLR PROPERTY
This is just a basic CLR property, but you must use GetValue() and SetValue() within the Get and Set accessors to make sure the CLR property works within the dependency property system.
2 CREATE THE CALLBACKS
This one’s optional, but if you need to coerce or validate the property values or want something to happen when the property changes, you’d create callback methods for those purposes. We’ll see how callbacks work at the end of this chapter.