Use Microsoft Expression Blend to edit the template of the PresenceIndicator control.

Editing the Template of a Lync control

The process used when editing the template of a Lync control requires an understanding of the standard process used in retemplating with Expression Blend. The PresenceIndicator is a relatively simple control to retemplate. Examining the steps involved in retemplating this control provides a foundation of understanding that can be applied to the editing of other more complex control templates. For more information on this process, please refer to the Expression Blend documentation.

To edit the PresenceIndicator control template

  1. In Expression Blend, open an existing application that contains an instance of a PresenceIndicator control which you wish to edit.

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

    Note 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 placing all of the templates into the same file to avoid namespace conflicts in the merged dictionary.

  3. Open the XAML file which contains the PresenceIndicator control which you wish to customize. On the View menu, click Active Document View and then click Design View.

  4. In the design view, right-click the PresenceIndicator control, click Edit Template, and then click Edit a Copy.

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

  6. The dictionary you created will now be populated with a variety of Style resources that are used by the PresenceIndicator, as well as a copy of the existing PresenceIndicator style, having the name that you specified.

    Note Note

    The sample code shown in below is from a WPF project. The actual XAML generated by Expression Blend will be slightly different if you are using Silverlight, but the process remains unchanged.

    In your form, Expression Blend will automatically apply the new style to your control. If you used the default name which was suggested by Expression Blend, the result should look something like this

      Copy imageCopy Code
    	<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 with a line like this

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

    In this style, you will find a copy of the template for the presence indicator.

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

    Search within the template for the Grid control which defines the core content of the PresenceIndicator. The name of this Grid is PART_Grid. Add a new resource to the Grid which defines a BlurEffect. Name this effect CameraShy, as shown below:

      Copy imageCopy Code
    	<Grid x:Name="PART_Grid">
    		<Grid.Resources>
    			<BlurEffect x:Key="CameraShy"/>
    		</Grid.Resources>
    
  8. A few lines down, you will see an Image control named PART_PhotoImageSmall. Add an attribute to this Image control to apply the new CameraShy effect which you defined above. The edited portions are shown below (leave the rest of the items in place):

      Copy imageCopy Code
    	<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