Expanded code samples

Lync 2013

What's new topic

Learn about the sample applications that are installed on your computer when you install Microsoft Lync 2013 SDK.

Last modified: December 07, 2015

Applies to: Lync 2013 | Lync Server 2013

In this article
Code samples overview
Quick-start samples
Reference samples
Additional resources

The sample collection includes quick-start samples that let you get started quickly with Lync development by demonstrating one Microsoft Lync 2013 API feature at a time. There is also a set of end-to-end samples that show how to put all the API features together to create a complete unified communication solution. You can download these samples from the MSDN samples code gallery. Links to individual code gallery samples are found in the How to topics where a corresponding sample is available to download.

The quick-start samples are grouped by API feature area. Many of these samples demonstrate Lync API features that have been in the API since the initial release of Lync, such as the presence-related samples that show how to use Lync Controls to display and update presence. The new Lync SDK features are demonstrated by the Persistent Chat, resource sharing, and content sharing samples.

Presence samples

The quick-start samples in the following table show how to publish and get presence for a contact by using presence controls or objects in the Lync 2013 API object model.

Application

Description

MyNotebox

Populates a page with a MyNoteBox control and displays the signed-in user’s display name and personal note in a text entry control.

  • WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\MyNoteBoxDesktop\MyNoteBoxDesktop.sln

  • Silverlight sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\MyNoteBoxSilverlight\MyNoteBoxSilverlight.sln

MyPresenceChooser

Populates a window with a MyPresenceChooser control that lets a user choose a presence activity. The resulting availability state is displayed in a text block on the page.

  • WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\MyPresenceChooserDesktop\MyPresenceChooserDesktop.sln

  • Silverlight sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\MyPresenceChooserDesktop\MyPresenceChooserSilverlight.sln

MyStatusArea

Populates a window with a MyStatusArea control that lets a user choose a presence activity and enter a personal note. Three text blocks on the page are bound to MyStatusArea control properties for the user display name, availability state, and personal note. The text value of these text blocks are automatically updated when the corresponding properties of the MyStatusControl change.

  • WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\MyStatusAreaDesktop\MyStatusAreaDesktop.sln

  • Silverlight sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\MyStatusAreaDesktop\MyStatusAreaSilverlight.sln

PresenceIndicator

Populates a list on a page with three PresenceIndicator instances. The user can hover a mouse pointer over any of the presence indicators to display a contact card for a user. The Source property for each control instance is set by the sample application.

  • WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\PresenceIndicatorDesktop\PresenceIndicatorDesktop.sln

  • Silverlight sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\PresenceIndicatorDesktop\PresenceIndicatorSilverlight.sln

Presence publication

Retrieve and publish information of the Self contact (the currently signed-in user) by using classes, enumerations, events, and methods of the Lync 2013 API. It also shows how to sign in to Lync using the credentials of the active user. The sample uses the following classes and methods:

Path: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
\microsamples.zip\PresencePublication\PresencePublication.sln

Contact samples

The contact samples in the following table show how to interact with Lync contacts by using the objects of the Lync 2013 API and controls from the Microsoft.Lync.Controls namespace.

Application

Description

ContactCard control list

Loads three ContactCard controls into a list on a page in a Silverlight or WPF application.

  • WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples\
    microsamples.zip\ContactCardDesktop\ContactCardDesktop.sln

  • Silverlight sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples\
    microsamples.zip\ContactCardDesktop\ContactCardSilverlight.sln

ContactList control

Populates a page with the ContactList control and then lists the SIP URI values for the contacts in the list.

  • WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\ContactListDesktop\ContactListDesktop.sln

  • Silverlight sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\ContactListDesktop\ContactListSilverlight.sln

CustomContactList control

Populates a page with a CustomContactList control and several child CustomContactListItem objects. The child objects are created and added at runtime by using C# code in a code-behind source file.

  • WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\CustomContactListAndcustomContactListItemDesktop
    \CustomContactListAndcustomContactListItemDesktop.sln

  • Silverlight sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\CustomContactListAndcustomContactListItemSilverlight
    \CustomContactListAndcustomContactListItemSilverlight.sln

ContactSearch control

Populates a page with a ContactSearch control and searches for used-by user name or skill.

  • WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples\
    microsamples.zip\ContactSearchDesktop\ContactSearchDesktop.sln

  • Silverlight sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\ContactSearchSilverlight\ContactSearchSilverlight.sln

Contact search with input box and search results

Populates a page with a ContactSearchInputBox control and a ContactSearchResultList control. The ContactSearchInputBox is bound to the ContactSearchResultList so that the resulting list displays search results based on what the user types in the search input box.

  • WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\ContactSearchInputBoxAndContactSearchResultListDesktop
    \ContactSearchInputBoxAndContactSearchResultListDesktop.sln

  • Silverlight sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\ContactSearchInputBoxAndContactSearchResultListSilverlight
    \ContactSearchInputBoxAndContactSearchResultListSilverlight.sln

Display frequent and favorite contacts

Populates a page with a list of favorite contacts and a list of frequent contacts. The sample uses the following classes and methods:

WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
\microsamples.zip\DisplayFrequentAndFavoriteContacts\DisplayFrequentAndFavoriteContacts.sln

Add and remove a custom group

Lists the groups in your contact list and lets you add or remove a group. The sample uses the Groups property, the BeginAddGroup method, and the BeginRemoveGroup method.

Path: %PROGRAMFILES(X86)%\Microsoft Lync\SDK\Samples
\microsamples.zip\AddCustomGroup\AddCustomGroup.sln

MoveContactBetweenGroups

Lists all custom groups in a user’s contact list and lets a user move a contact from one custom group to another. The sample uses the following classes and methods:

Path: %PROGRAMFILES(X86)%\Microsoft Lync\SDK\Samples
\microsamples.zip\MoveContactBetweenGroups\MoveContactBetweenGroups.sln

Add and remove a contact from a group

Adds and removes contacts from the Other Contacts group. The sample uses the following classes and methods:

Path: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
\microsamples.zip\AddRemoveContacts\AddRemoveContacts.sln

Conversation samples

The conversation samples in the following table show how to interact with Lync conversations by using the objects of the Lync 2013 API and Lync Controls from the Microsoft.Lync.Controls namespace.

Application

Description

ButtonsDesktop

Shows how to display Lync conversation-starting controls in a list. The Source property for each control is set to the URI of a user. The controls used in the sample include: StartInstantMessagingButton, StartAudioCallButton, StartVideoCallButton, ShareDesktopButton, SendFileButton, SendEmailButton, and ScheduleMeetingButton.

  • WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\ButtonsDesktop\ButtonsDesktop.sln

  • Silverlight sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\ButtonsSilverlight\ButtonsSilverlight.sln

AcceptConversation

Displays a window that registers for the ConversationAdded event and then notifies the user when a conversation invitation is received. If the user chooses to ignore the invitation, the window ends the new conversation. The sample uses the following classes and methods:

WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
\microsamples.zip\AcceptConversation\AcceptConversation.sln

StartConversation

Start an IM conversation using the ConversationManager class. Messages are sent using plain text.

  • WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\StartConversation\StartConversation.sln

StartFormattedConversation

Start an IM conversation using the ConversationManager class. Messages are sent in the MIME type selected by the user.

  • WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\StartFormattedConversation\StartFormattedConversation.sln

DockingConversationWindowSample

Start and dock an IM conversation using the StartInstantMessagingButton control.

  • WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \DockingConversationWindowSample\DockingConversationWindowSample.csproj

MeetNow

Start a meet-now conference using automation

  • WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\MeetNow\MeetNow.sln

JoinMeetingFromLobby

Joins a running meeting and notifies the users if they are in the meeting lobby.

  • WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
    \microsamples.zip\JoinMeetingFromLobby\JoinMeetingFromLobby.sln

Automation conversation

This sample uses the Automation class in the Lync 2013 API to start a new conversation with one or more Lync contacts. Features include the following:

  • The sample uses the Automation API in Lync to start a new conversation with a set of Lync contacts.

  • The conversation can be started with one or more modalities at the same time.

  • The sample shows how to set up specific settings for each conversation modality.

Path: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
\Automation\Automation.csproj

Conversation Window Docker

This application demonstrates the ability to dock a conversation window within another WPF application. The sample:

  • Docks a conversation window into a WPF application.

  • Demonstrates how to use a WindowsFormsHost to dock a conversation window.

  • Shows how to handle the different events raised by a conversation window.

  • Shows how to flash the window when the conversation window requires attention.

Path: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
\DockingConversationWindowSample\DockingConversationWindowSample.csproj

Audio/Video Conversation

This sample uses the Microsoft.Lync.Model.Conversation and Microsoft.Lync.Model.Conversation.AudioVideo namespaces from the Microsoft Lync 2013 API to implement a conversation window. The sample:

  • Implements a fully functional audio/video conversation window.

  • Shows how to register and handle conversation manager and audio/video conversation events.

  • Uses the most common features of Conversation, AVModality, AudioChannel, and VideoChannel.

Path: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
\AudioVideoConversation\AudioVideoConversation.csproj

Persistent Chat samples

The following sample applications demonstrate how to add chat room features to a Microsoft Lync 2013 SDK-enabled application.

Application

Description

GetMessages

The GetMessages sample application shows how to get messages that have been posted to a Persistent Chat room and then display any new message that are posted to the chat room. In addition, the sample shows how to get the chat rooms that are in a user’s contact list and keep that room collection synchronized with the contact list.

Path: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
\microsamples.zip\PersistentChat_GetMessages\PersistentChat_GetMessages.sln

FollowedRoomList

The FollowedRoomList sample application shows how to get the Persistent Chat rooms that are in a user’s contact list and then keep that room collection synchronized with the contact list. For information about how to find Persistent Chat rooms that are not in a user’s contact list, see "RoomQuery" application later in this topic.

Path: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
\microsamples.zip\PersistentChat_FollowedRoomList\PersistentChat_FollowedRoomList.sln

RoomQuery

The RoomQuery sample application shows how to get a collection of Persistent Chat rooms that are not in a user’s contact list. For information about finding Persistent Chat rooms that are in a user’s contact list, see "FollowedRoomList" application earlier in this topic.

Path: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
\microsamples.zip\PersistentChat_RoomQuery\PersistentChat_RoomQuery.sln

PostMessage

The PostMessage sample application shows how to post a plain-text message to a Persistent Chat room in a user’s contact list and verify that the message posted successfully. In addition, the sample shows how to get a chat room from the contact list.

Path: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
\microsamples.zip\PersistentChat_PostMessage\PersistentChat_PostMessage.sln

GetParticipants

The GetParticipants sample application shows how to get a list of Persistent Chat room participants. In addition, the sample shows how to get a chat room from the contact list.

Path: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
\microsamples.zip\PersistentChat_GetParticipants\PersistentChat_GetParticipants.sln

FilterMessageAddIn

The FilterMessageAddIn sample application shows how to get a hosting group for a Persistent Chat room, catch outgoing messages before they are posted to the hosting chat room, run filtering and formatting logic on the messages, and then send the resulting message to the hosting chat room.

Path: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
\microsamples.zip\PersistentChat_FilterMessageAddin\PersistentChat_FilterMessageAddIn.sln

Content sharing samples

The following sample application demonstrates how to share whiteboards, PowerPoint slide decks, and native file attachments in a conversation.

Application

Description

ContentModalitySample

Shows how to create a conversation and then share a whiteboard and a PowerPoint slide deck. If a PowerPoint slide deck is shared, the sample lets a user scroll forward and backward in the slide deck. The sample uses the following classes and methods:

WPF sample location: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
\microsamples.zip\ContentSharingModality

The following samples provide complete application examples using the Lync 2013 API. These examples illustrate the use of Lync 2013 API in real-world scenarios.

Conversation translator

This sample uses the Microsoft.Lync.Model.Conversation namespace from the Lync Model API to intercept instant messages and provide translation using Bing Web Services.

Features include the following:

  • The sample provides an example architecture for registering for and handling asynchronous Lync 2013 API events in Silverlight.

  • Register for two Conversation related events: ParticipantAdded and InstantMessageReceived.

  • Use the BeginSendMessage method and callback.

  • Uses the Bing Translator Web Service.

Path: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
\ConversationTranslator\ConversationTranslator.csproj

Proposal tracker

The ProposalTracker application demonstrates the use of Microsoft Lync Controls in a Silverlight application. The application is a demonstration, representing a tool used by a fictitious company called Fabrikam, Inc. It tracks a list of proposals and sales people in the company.

Features include the following:

  • Demonstrates how to use the following Lync Controls in a Silverlight application:

    • MyStatusArea control

    • PresenceIndicator control

    • ContactCard control

    • ContactList control

    • CustomContactList control

    • ContactSearchInputBox control

    • ContactSearchResultList control

  • Demonstrates how to use ContextualConversation between two conversation windows with the companion application MiniProposalTracker, which runs in a Lync Conversation Window Extension.

Path: %PROGRAMFILES(X86)%\Microsoft Office 2013\LyncSDK\Samples
\ProposalTracker\ProposalTracker.sln

Show: