This blog has, IMO, some great resources. Unfortunately, some of those resources are becoming less relevant. I'm still blogging, learning tech and helping others...please find me at my new home on http://www.jameschambers.com/.

Tuesday, April 21, 2009

Spike.Prototype

Today I laid roots for the start of the helpdesk monitor, a full-screen WPF application that talks to a couple of webservices and keeps everyone at the helpdesk in tune with the calls that are in the queue and who’s talking to whom.

In developing WPF applications and the corresponding classes that will feed those apps, I’ve found that one of the biggest mind shifts for developers would be the use of dependency properties.

They are fairly trivial to implement, and the benefits are wonderful.  With the binding, animation and styling elements that come into play in WPF, they are also mandatory learning.

Adding a dependency property – which must be in a class that inherits from DependencyObject or one of its inheritors – is as simple as setting up a property as you normally would, and then using the static Register method on the DependencyProperty object.  Your getters and setters then just reference the DP you’ve setup, and at that point the internals of the .Net framework take care of the heavy lifting.

public string AgentName
{
get { return (string)GetValue
AgentNameProperty); }
set { SetValue(AgentNameProperty,
value); }
}

public static readonly DependencyProperty
AgentNameProperty =
DependencyProperty.Register("AgentName",
typeof(string), typeof(CallItem),
new UIPropertyMetadata("(Unknown)"));




As a developer we can now leverage the very cool binding benefits of our class, such that if anyone/thing/class/event changes the value of our property we can automagically start playing an animation and/or update our user interface without effort.  Seamless binding syntax in XAML allows for easy Observer-style up-to-datedness without having to do backflips or write a ton of boilerplate code.



Hrm…seems I need to find a better format for my blog posts where I’ll be pasting in code…

No comments:

Post a Comment