This topic demonstrates how to set the
Prerequisites
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.
Copy Code | |
---|---|
<controls:PresenceIndicator Source="sip:mary@contoso.com"/> |
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
Set the Source Property to a String
The following walkthrough sets
Name
as an extended attribute in XAML to allow the
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.
Copy Code <controls:PresenceIndicator x:Name="presenceIndicator"/>
-
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.
Copy Code presenceIndicator.Source = "sip:mary@contoso.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.
Copy Code 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.
Copy Code Client client = LyncClient.GetClient(); Contact contact = client.ContactManager.GetContactByUri("sip:bob@contoso.com"); 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.