Use Microsoft Expression Blend to edit the template of the
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
To edit the PresenceIndicator control template
-
In Expression Blend, open an existing application that contains an instance of a PresenceIndicator control which you wish to edit.
-
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 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.
-
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.
-
In the design view, right-click the PresenceIndicator control, click Edit Template, and then click Edit a Copy.
-
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.
-
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 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 Code <controls:PresenceIndicator Source="sip:scott@contoso.com" PhotoDisplayMode="Large" Style="{DynamicResource PresenceIndicatorStyle1}"/>
-
Open up the resource dictionary and locate your new PresenceIndicator style. The XAML for the style will begin with a line like this
Copy 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 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 Code <Grid x:Name="PART_Grid"> <Grid.Resources> <BlurEffect x:Key="CameraShy"/> </Grid.Resources>
-
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 Code <Image x:Name="PART_PhotoImageSmall" Effect="{StaticResource CameraShy}"
-
Run the project, and observe the blurring effect. The presence photo is now enhanced for camera shy persons!