Browsing and opening items with the ContentBrowser

The ContentBrowser can be used to allow users to browse or search for an item stored in an ArcGIS account online in a modal dialog box. This may typically be used to within a customization dialog box for a custom widget, map tool, or feature action, to allow an operation view author to choose a service item as a configurable setting. For example, the application Configure Map Widget dialog box allows the author to find and select a webmap stored online to be used in a map widget, and the Configure Find Places dialog box allows the author to find and select an online geocoding service to be used by the map tool.

The ShowDialog method shows the dialog in a modal style. When the user selects an item and clicks the Open button to choose the item and dismiss the dialog box, an ArcGISPortalItem representing the selected item is returned.

The browser supports browsing for web maps, and also for geocoding, geometry, geoprocessing, and network analysis services.

How to use the ContentBrowser

  1. Create a ContentBrowser variable, passing in the owner window, the type to be browsed for and the dialog box caption to the constructor.
  2. Call the ShowDialog method to show the dialog.
  3. Check the result returned from the ShowDialog method, and use the SelectedItem property to find the item that was selected.

ContentBrowser C# example

// Find the Window representing the current application.
Window win = Window.GetWindow(this);
            
// Create a content browser to browse for GP services.
BrowseItemType type = BrowseItemType.GeoprocessingService;
ContentBrowser browse = new ContentBrowser("Select an item type:", type, win);
            
// Show the dialog, and once it has been dismissed by the user, retrieve the selected item.
bool result = browse.ShowDialog();
if (result)
{
  ESRI.ArcGIS.Client.Portal.ArcGISPortalItem selectedGpItem = browse.SelectedItem;
  // Use the GP service as required. For example, a client GP Task can be defined against 
  // the Url property of the selected item:
  // ESRI.ArcGIS.Client.Tasks.Geoprocessor gp = new client.Tasks.Geoprocessor(selectedGpItem.Url);
 }

ContentBrowser Visual Basic example

' Find the Window representing the current application.
Dim win As Window = Window.GetWindow(Me)
            
' Create a content browser to browse for GP services.
Dim type As BrowseItemType = BrowseItemType.GeoprocessingService
Dim browse As ContentBrowser = New ContentBrowser("Select an item type:", type, win)
            
' Show the dialog, and once it has been dismissed by the user, retrieve the selected item.
Dim result As Boolean = browse.ShowDialog()
If (result) Then
  Dim selectedGpItem As ESRI.ArcGIS.Client.Portal.ArcGISPortalItem = browse.SelectedItem
  ' Use the GP service as required. For example, a client GP Task can be defined against 
  ' the Url property of the selected item:
  ' ESRI.ArcGIS.Client.Tasks.Geoprocessor gp = new client.Tasks.Geoprocessor(selectedGpItem.Url);
End If
1/27/2015