Compartir a través de


Editing the Template of a Lync 2010 Control

Learn how to edit a Microsoft Lync 2010 Control template by using Microsoft Expression Blend to edit the PresenceIndicator control template.

Editing a Lync Control Template

The process that is used to edit a Microsoft Lync Control template requires comprehension of the standard process that is used to edit templates with Expression Blend. The PresenceIndicator control is a fairly simple control to retemplate. For information about retemplating complex templates, see the Expression Blend documentation.

To edit the PresenceIndicator control template

  1. In Expression Blend, open an existing application that contains a PresenceIndicator instance.

  2. On the Project menu, click Add New Item, and then select Resource Dictionary. This dictionary is used to hold the resources for the custom styles, templates, and related items that are targeted for edit. Give the new dictionary a name, and then click OK.

    Note

    Many Lync Controls share a common set of base styles and resources. If you plan to customize the appearance of more than one Lync Control, you should consider positioning all of the templates into one folder to avoid namespace conflicts in the merged dictionary.

  3. Open the XAML file that contains the PresenceIndicator control that you want to customize, and then on the View menu, click Active Document View and then click Design View.

  4. In design view, right-click the PresenceIndicator control, click Edit Template, and then click Edit a Copy. The Create Style Resource dialog box appears.

  5. In the Create Style Resource dialog box, enter a name for the style and then select the Define in Resource dictionary option. Choose the dictionary that you created earlier, and then click OK.

  6. The dictionary that you created is now populated with various Style resources that are used by the PresenceIndicator control, and a copy of the existing PresenceIndicator style that you named previously.

    Note

    The next XAML example is from a Microsoft Windows Presentation Foundation (WPF) project. The actual XAML generated by Expression Blend will be slightly different if you use Microsoft Silverlight, but the process remains unchanged.

    In your form, Expression Blend automatically applies the new style to your control. If you used the default name generated by Expression Blend, the result should resemble the following XAML.

        <controls:PresenceIndicator 
                   Source="sip:scott@contoso.com" 
                   PhotoDisplayMode="Large" 
                   Style="{DynamicResource PresenceIndicatorStyle1}"/>
    
  7. Open up the resource dictionary and locate your new PresenceIndicator style. The XAML for the style will begin in the following manner.

            <Style x:Key="PresenceIndicatorStyle1" 
                   TargetType="{x:Type controls:PresenceIndicator}">
    

    In this style, a copy of the template for the presence indicator appears.

    <Setter Property="Template">
       <Setter.Value>
    <ControlTemplate TargetType="{x:Type controls:PresenceIndicator}">
    

    Search within the template for the Grid control that defines the core content of the presence indicator. The name of this Grid is PART_Grid. Add a new resource to the Grid that defines a BlurEffect named CameraShy.

        <Grid x:Name="PART_Grid">
            <Grid.Resources>
                <BlurEffect x:Key="CameraShy"/>
            </Grid.Resources>
    
  8. A few lines down, an Image control named PART_PhotoImageSmall appears. Add an attribute to this Image control to apply the new CameraShy effect defined earlier. The edited portions appear next. All other items should remain static with edited items.

        <Image x:Name="PART_PhotoImageSmall" Effect="{StaticResource CameraShy}"
    
  9. Run the project and observe the blurring effect. The presence photo is now enhanced for camera shy persons!

See Also

Concepts

Retemplating Lync 2010 Controls