This topic demonstrates how to set the property of Microsoft Lync Controls. Use the Source property to get or set contact and group URIs for Lync Controls using Microsoft Lync 2010 SDK. For more information, see Understand the Source Property .
For a list of prerequisites, see Walkthrough: Presence Hello World .
Using the Source Property in XAML
In the XAML Designer, set the Source property to a string.
Using the Source Property in C#
The following two procedures show how to use C# in the code-behind file to set the Source property of a Lync Control control to a Stringor to a object.
Set the Source Property to a String
The following walkthrough sets Name as an extended attribute in XAML to allow the control to be referenced in the C# code editor, and then sets the Source property to a string value.
To create the String type walkthrough application
Create a Microsoft Windows Presentation Foundation (WPF) Lync Controls application. For more information, see Walkthrough: Presence Hello World .
On the Window1.xaml page, find the XAML creating the PresenceIndicator control. Ensure that an extended Name attribute is added, and the Source property is not set, as in the following example.
On the Window1.xaml.cs page, add the following statement in the Window1 constructor following the call to InitializeComponent . Edit the URI to provide a valid value.
presenceIndicator.Source = "sip:email@example.com";
Press F5 to build and run the application. The PresenceIndicator control displays the correct presence status for the contact specified using a string in C#.
Set the Source Property to a Contact Object
The following walkthrough uses the GetContactByUri method to return a specific contact, sets the contact to a Contact object, and then sets the Source property to the Contact object.
To create the Contact object walkthrough application
Use steps 1 and 2 from the previous procedure to create a simple application that contains a PresenceIndicator control with the Name attribute added and the Source property not set, as shown in the previous procedure.
In Window1.xaml.cs, add the following using statements.
using Microsoft. Lync.Model; using Microsoft.Lync.Model.Extensibility;
Add the following statements to the Window1constructor following the call to InitializeComponent . Edit the URI to provide a valid value.
Client client = LyncClient.GetClient(); Contact contact = client.ContactManager.GetContactByUri("sip:firstname.lastname@example.org"); presenceIndicator.Source = contact;
Press F5 to build and run the application. The PresenceIndicator control displays the contact set by the Source property in the previous step.