Share via


Building a dialog to pick workitems

This post is a tip if you ever wanted to build a dialog in your app to pick workitem(s). You might have seen the work item picker dialog below in TFS to select one or few workitems, such as when adding a work item link. If you ever wanted to use this dialog in your own application, you might have seen that this dialog is not exposed and hence cannot be used unfortunately.  

However such a dialog can be built very easily because the control inside that dialog is exposed. PickWorkItemsControl is the control name and is part of Microsoft.TeamFoundation.Controls namespace. This is available in Microsoft.TeamFoundation.Common.Library.dll. Here is how to create the control and set project name to show supposing you have a large panel in your dialog:

private void AddPickWorkItemsControlToPanel(WorkItemStore store, Panel panel)

{

PickWorkItemsControl c = new PickWorkItemsControl(store, /* multiselect */ true);

c.PortfolioDisplayName = "Demo Project";

c.Dock = DockStyle.Fill;

panel.Controls.Add(c);

}

In the Ok button, the selected workitems are available in SelectedWorkItems() method. This approach is also used in custom controls sample. BTW, many workitem controls like result list, work item form etc are exposed for use in custom applications and WIBrowser sample in VSSDK shows how to use them.