Monthly Archives: October 2010


One of the cool features of dependency properties is that there is a nice, cheap and easy way to incorporate notifications using them. (Note, however, that a more sophisticated notification system may be required by your needs and would otherwise have to be implemented in a different way).

There’s this class called DependencyPropertyDescriptor. MSDN says, “Provides an extension of PropertyDescriptor that accounts for the additional property characteristics of a dependency property.” So, it inherits from the abstract class, PropertyDescriptor, which “Provides an abstraction of a property on a class.”

You can create a DependencyPropertyDescriptor object using its class’ static method “FromProperty”. Then, all you need to do is call the AddValueChanged method, passing in a control and a callback method, and then whenever that property’s value changes, the callback method will be invoked. The following code is a portion of the code-behind for the demo which can be downloaded by clicking here:

            DependencyPropertyDescriptor dpd =

            //  Now add btnHi to the descriptor. Note that btnBye is not added.
            dpd.AddValueChanged(btnHi, HeightValueChanged);

The callback method is simply:

        private void HeightValueChanged(Object sender, EventArgs e)
            MessageBox.Show("height is now " + ((Button)sender).Height.ToString());

And the rest you can see in the download code.

Service XXX.ABCService is not available in the current context

Working with a new module of the Web Client Software Factory that I had created, I was getting an error similar to that seen in the screenshot on this page. I trouble-shot everything suggested on that page, and everything on this page.

None of those situations applied in my case. Upon a closer inspection, I had totally made a noob error. In the presenter, I had injected the concrete implementation of the Service, rather than the interface upon which the service had been implemented. So, if you see that error about a service not being available in the current context, it may be something as simple as that.