Retemplating the ContactSearch control

Beyond the basics topic

Learn about visual template editing for individual parts of the ContactSearch control by using a step-by-step procedure to generate a visual template for a control part and adding elements to the template.

Applies to: Lync 2013 | Lync Server 2013

In this article
ContactSearch control overview
Edit the ContactSearchResultlistitem templates
Additional resources

ContactSearch control overview

The template for the ContactSearch control includes two parts:

To change the appearance of either control, embed them in your project individually and then retemplate the control.

Edit the ContactSearchResultlistitem templates

To modify the templates used to display search results within the ContactSearchResultList control, use a technique similar to the one used to edit contact list items in Retemplating the ContactList control.

ContactSearchResultList uses a variety of DataTemplate resources to control the appearance of people, telephone numbers, bots, and distribution lists. To customize the DataTemplate for one or more of these contact types, complete the following procedure.

To edit the ContactSearchResultListItem templates

  1. Before you begin, temporarily add a reference to the following namespace in your form.

    xmlns:internal=
    "clr-namespace:Microsoft.Lync.Controls.Internal;assembly=Microsoft.Lync.Controls"
    
  2. The template for a contact search result is applied to an internal control type called ContactSearchResultListItem. This control is not directly accessible from the ContactSearchResultList template. To get a copy of the templates used by ContactSearchResultListItem, you must temporarily add an instance of ContactSearchResultListItem to your form, and then edit a copy of its template.

    <internal:ContactSearchResultListItem/> <!-- For temporary use -->
    
    Important noteImportant

    Before moving to step 3, ensure that you reference the internal namespace defined earlier.

  3. After you save a copy of the template, delete ContactSearchResultListItem and the internal namespace definition from your form.

  4. In the resulting set of resources, styles and templates used by the ContactSearchResultListItem control appear. The DataTemplate objects can be used to customize the appearance of contacts in the ContactSearchResultList control. For example, you can modify the template used to display person-type contacts by customizing the data template that is identified by the key PersonSearchResultItemDataTemplate template. After you make your changes, apply the new template by setting the following property on the ContactSearchResultList control.

    <controls:ContactSearchResultList 
            PersonItemTemplate="{StaticResource PersonSearchResultItemDataTemplate}"/>
    

The following table identifies the templates that can be used to customize the appearance of contacts in the ContactSearchResultList control.

Contact type

ContactSearchResultList property name

Name of corresponding DataTemplate

Person

PersonItemTemplate

PersonSearchResultItemDataTemplate

Telephone

TelephoneItemTemplate

TelephoneSearchResultItemDataTemplate

Bot

BotItemTemplate

BotSearchResultItemDataTemplate

Group

GroupItemTemplate

DistributionListSearchResultItemDataTemplate

See also

Visual template editing for Lync Controls that use contentPresenters