Retemplating the ContactList control

Beyond the basics topic

Learn about visual template editing for individual parts of the ContactList 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
ContactList control overview
Edit the ContactListGroupItem template
Edit the ContactListItem templates
Additional resources

ContactList control overview

Similar to the ContactCard control, there are several parts to a ContactList control that you can customize. The ContactList control includes two parts:

  • The tree view that presents the hierarchical display of groups and contacts.

  • The toolbar that appears at the top of the contact list.

With Microsoft Expression Blend, you can edit a copy of the template for the ContactList control to customize the toolbar or add an additional component to the basic template for a ContactList control. However, to modify the appearance or behavior of the nodes within the tree view control, additional steps are required.

Edit the ContactListGroupItem template

To customize the template that is used to display top-level group nodes on the ContactList control, complete the following procedure.

To edit the ContactListGroupItem template

  1. The template for a group-level node is applied to an internal control type called ContactListGroupItem. This control is not directly accessible from the ContactList template. To get a copy of the template for a ContactListGroupItem control, you must temporarily add an instance of ContactListGroupItem to your form, and then edit a copy of its template.

    <controls:ContactListGroupItem/> <!-- For temporary use -->
    
  2. In the resulting set of resources, a new style and control template for ContactListGroupItem appears.

    If you accepted the suggested name for the new style, output that resembles the following appears.

        <Style x:Key="ContactListGroupItemStyle1" 
            TargetType="{x:Type controls:ContactListGroupItem}">
    
  3. Delete the reference to the ContactListGroupItem control that you created in step 1.

  4. Add final changes to the style and the embedded control template.

    When complete, you can use the new style and template in your ContactList control by setting the GroupItemContainerStyle property.

        <controls:ContactList 
            GroupItemContainerStyle="{StaticResource ContactListGroupItemStyle1}"/>
    

Edit the ContactListItem templates

The ContactList control uses a variety of DataTemplate resources to control the appearance of people, telephone numbers, bots, and nested distribution groups. There are two data templates for each type of contact:

  • Name View data template

  • Picture View data template

These views are sometimes referred to as OneLine and TwoLines view, respectively.

To customize the DataTemplate for one or more views

  1. The template for a contact-level node is applied to an internal control type called ContactListItem. This control is not directly accessible from the ContactList template. To get a copy of the template for a ContactListItem, you must temporarily add an instance of ContactListItem to your form, and then edit a copy of its template.

    <controls:ContactListItem/> <!-- For temporary use -->
    
  2. After you save a copy of the template, delete ContactListItem from your form.

    In the resulting set of resources, styles and templates used by the ContactListItem control appear. The DataTemplate objects can be used to customize the appearance of contacts in the ContactList control.

    For example, you can modify the template used to display person-type contacts in TwoLines view by customizing the data template that is identified by the key PersonContactItemDataTemplateTwoLines template. After you make your changes, apply the new template by setting the following property on the ContactList control.

    <controls:ContactList PersonTwoLineItemTemplate=
            "{StaticResource PersonContactItemDataTemplateTwoLines}"/>
    

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

Contact type

Layout view

ContactList property name

Name of corresponding DataTemplate

Person

OneLine

PersonItemTemplate

PersonContactItemDataTemplateOneLine

Person

TwoLines

PersonTwoLineItemTemplate

PersonContactItemDataTemplateTwoLines

Telephone

OneLine

TelephoneItemTemplate

TelephoneContactItemDataTemplateOneLine

Telephone

TwoLines

TelephoneTwoLineItemTemplate

TelephoneContactItemDataTemplateTwoLines

Bot

OneLine

BotItemTemplate

BotContactItemDataTemplateOneLine

Bot

TwoLines

BotTwoLineItemTemplate

BotContactItemDataTemplateTwoLines

Group

OneLine

GroupItemTemplate

GroupContactItemDataTemplateOneLine

Group

TwoLines

GroupTwoLineItemTemplate

GroupContactItemDataTemplateTwoLines

See also

Visual template editing for Lync Controls that use contentPresenters