WPF Presence Controls for Office Communicator 2007
We recently built a set of WPF presence controls to use with Office Communicator 2007 applications.
The WPF presence controls are now available for download on MSDN.
We've used these controls in several WPF applications, including the Microsoft Office Communicator Vista Gadget project that we just published on CodePlex.
The MSDN download includes the complete source code of the presence controls, along with a sample application that shows the various ways of using them.
Note: The MSI installs the source code into a directory under C:\Program Files\ by default. Visual Studio doesn't seem to play nice with solutions that live there. Before attempting to compile the solution, I recommend moving the files to another location, and changing them so that they're not read-only.
Configurability / Extensibility
An important goal when building these controls was to expose their properties to the developer as configurable options. We wanted to ensure that the developer could tailor the use of the controls specifically to their application. All of these properties are exposed as WPF Dependency Properties.
Additionally, the controls are built in such a way so that a developer can use them as building blocks for other controls. We followed that mantra ourselves when building the controls, e.g. the PersonaList and MyPersona controls are built on top of the Persona control.
Presence Controls
The project includes three controls:
- Persona
- PersonaList
- MyPersona
Persona
The Persona control is used to display the presence and availability of a single user.
The Persona control exposes the following properties:
- SipUri
- The Sip URI of the contact to bind the Persona control to
- ShowContextMenu
- Show the Persona control's context menu via right-click
- The context menu provides options for communicating with the contact
- ShowDisplayName
- Show the display name of the contact with the given Sip URI
- ShowAvailability
- Show the availability (availability != presence) of the contact
- ShowToolTip
- Show a summary tooltip when hovering over the control
- ShowDetailedToolTip
- Show a more detailed tooltip (includes some calendar information) when hovering over the control
- UseLargePNGPresenceImages
- When set to true, the Persona control uses 24x24 images to display presence
- If not set, the control uses the small 16x16 images to display presence
- UseXAMLPresenceImages
- The control displays presence using vector images instead of PNGs
- CustomMenuItemList
- Allows you to extend the control's context menu with custom menu items
- Can only be set in code behind
As you can see, some of these properties are mutually exclusive. For example if set to True, UseXAMLPresenceImages would override UseLargePNGPresenceImages.
Most of the properties can be set either declaratively in XAML, or in the code behind.
By default, when you drop a Persona control into your XAML, none of its properties are specified (they default to false).
When UseXAMLPresenceImages is set to True, the presence images are rendered using vector images. The Persona control is them only bound by the size of the item containing it.
Oh yeah, big presence.
PersonaList
The PersonaList is simply a list of Persona controls, you can use this to display the presence and availability of a set of users.
The PersonaList exposes a SipUris property of type List<String>, you can set this property in your code behind:
The PersonalList control exposes all the properties exposed by PersonaList except for UseXAMLPresenceImages and SipUri (which is replaced by SipUris).
Out of the box, the PersonaList looks pretty bland. However, using the Persona control, you can build your own PersonaList that has its own specific look and feel, e.g. a hover and selected style. Gotta love WPF.
You can set the properties exposed by the underlying Persona control to whatever you like, e.g. you might not want to have a tooltip on the Persona control in your implementation of PersonaList.
MyPersona
The last control is the MyPersona control, which displays the availability and status of the currently signed in user. The developer isn't able to set the user that this control is bound to.
The little arrow exposes a context menu that the user can use to change their status, similar to how you can do this in the main Office Communicator window.
Custom Context Menu Items
The Persona control's (and PersonaList) context menu can be extended to include custom menu items defined by the developer. I'll leave that for another blog post, but there's a good example in the sample application that's available with the source code.
Non-Contacts
Nothing is there to stop you from pointing a Persona control at a contact that is not on your contact list. Office Communicator caches the presence of such contacts, and may show you their presence initially. However, it will not get presence update events for contacts not on your list.
To be specific, there is no guarantee that a ContactStatusChange event will be raised for a contact that is not on your contact list.
This is a security feature intended to prevent people from seeing the presence and availability of contacts not on their list. However, the controls seem to get presence updates correctly if the contact was previously in the contact list.
We made a design tradeoff to "gray out" presence icons for contacts that are not on the current user's contact list. We went with this approach because Office Communicator seemed inconsistent as to which contacts (not on the user's list) it would show correct presence for.
An important thing to note is that since Communicator allows you to add distribution lists as contacts. Members of those distribution lists are not in your contact list by default.
Feedback
I hope you find these controls useful. It seems that until now, the only other good option was to host the old Windows Forms Presence Controls in WPF.
If you have any feedback for improvement, or come across a bug or issue, please contact me.