New Work Item Type Controls in TFS 2010
The following post was written by Smitha Saligrama, a software development engineer in test for the work item tracking team in TFS.
With the release of TFS 2010, there are some new work item controls you can take advantage of.
Stand-alone Label
You can now have a stand-alone label control on the work item form without having to attach the label to another control.
These labels can have
- Plain text
- Static hyperlinks
- Dynamic hyperlinks with data coming from work item fields or work item macros
Example 1: Stand-alone label with plain text
<Control Type="LabelControl" Label="Standalone Label Text" ></Control>
Or
<Control Type="LabelControl">
<LabelText>
<Text>Standalone label text</Text>
</LabelText>
</Control>
Output:
Example 2: Stand-alone label with static hyperlinks
<Control Type="LabelControl">
<LabelText>
<Text>Follow this link <Link UrlRoot="https://www.msn.com/"/> Thank you.</Text>
</LabelText>
</Control>
Output:
Example 3: Standalone label with dynamic hyperlinks
Supported macros: @ReportServiceSiteUrl, @ReportManagerUrl, @PortalPage, @ProcessGuidance, @Me
<Control Type="LabelControl">
<LabelText>
<Text>
<Link UrlRoot="@PortalPage" UrlPath="{0}/default.aspx">
<Param Index="0" Value="System.State" Type="Current"/>
</Link>LinkLabelExample</Text>
</LabelText>
</Control>
Output:
Url :
Link Label
You can now have links on the labels that are associated with your controls.
Links can be:
- Static hyperlinks
- Dynamic hyperlinks with data coming from work item fields or work item macros
Example 1: Link label with static hyper link
<Control Type="FieldControl" FieldName="Test.Test1" Label="Link Label Example" LabelPosition="Left">
<Link UrlRoot="https://www.msn.com/"/>
</Control>
Or
<Control Type="FieldControl" FieldName=" Test.Test1" LabelPosition="Left">
<LabelText>
<Text>
<Link UrlRoot="https://www.msn.com/"/>Link Label Example</Text>
</LabelText>
</Control>
Output:
Example 2: Link label with dynamic hyper link
Supported macros: @ReportServiceSiteUrl, @ReportManagerUrl, @PortalPage, @ProcessGuidance, @Me
<Control Type="FieldControl" FieldName=" Test.Test1" LabelPosition="Left">
<LabelText>
<Text>
<Link UrlRoot="@PortalPage" UrlPath="{0}/default.aspx">
<Param Index="0" Value="System.State" Type="Current"/>
</Link>Example
</Text>
</LabelText>
</Control>
Output:
Url :
Webpage Control
Webpage controls are now supported.
Webpage controls can have
- CDATA for rendering HTML
- A web page URL for rendering an actual webpage.
Example 1: CDATA
<Control Type="WebpageControl">
<WebpageControlOptions>
<Content>
<![CDATA[Click here for detailed <b><a href="https://www.microsoft.com"> on the company</a></b>]]>
</Content>
</WebpageControlOptions>
</Control>
Output:
Example 2: Web Page
<Control Type="WebpageControl">
<WebpageControlOptions ReloadOnParamChange="true">
<Link UrlRoot="@PortalPage"/>
</WebpageControlOptions>
</Control>
Output:
Comments
Anonymous
May 25, 2010
Hi, great overview of these new controls, but is it also possible to use data from the WI to create an URL. Lets say I want to have a link to google and use the title of the WI to use as search phrase. Can I embed that into the URL? And is that also possible with custom fields I've added to the WI?Anonymous
June 01, 2010
Hi Youri, Yes, your scenario is possible with linked labels (see the above examples). In your case, you can do the following: <Control Type="LabelControl"> <LabelText> <Text> <Link UrlRoot="http://www.google.com/" UrlPath="#q={0}"> <Param Index="0" Value="System.Title" Type="Current"/> </Link>LinkLabelExample</Text> </LabelText> </Control> If you want to use the webpage control to open a webpage to show that Google search, you can do the following: <WebpageControlOptionsType"> <WebpageControlOptions ReloadOnParamChange="true"> <Link UrlRoot="http://www.google.com/" UrlPath="#q={0}"> <Param Index="0" Value="System.Title" /> </Link> </WebpageControlOptions> </WebpageControlOptionsType> JonAnonymous
June 23, 2010
Note: If you are edited an old WITD to include these new control, please change the WITD schema to point to the new verion. <?xml version="1.0" encoding="utf-8" ?> <witd:WITD application="Work item type editor" version="1.0" xmlns:witd="schemas.microsoft.com/.../typedef">