How to find a widget

The Widgets property on the OperationsDashboard class provides a way to get a reference to the IWidget interface of any widget in the current operation view. Custom widgets can be cast to their specific type if known. Map widgets can be cast to the MapWidget type in order to access map specific properties; see the Working with the Map topic for advice. For other out-of-the-box widgets, only the IWidget interface is accessible.

How to find a specific widget by ID

If the persisted IWidget.ID property of a widget is known, a reference to that widget can be found by using the Where Linq extension method and the Widgets collection property on the OperationsDashboard class. By using this and other Linq extension methods, it is simple to get references to any widget or widgets by property values, for example by using a specific IWidget.Caption in a Where call.

Find a widget from Widgets collection by ID

IWidget idWidget = OperationsDashboard.Instance.Widgets.Where(w => w.Id == knownIdString).FirstOrDefault() as IWidget;

Find a widget from Widgets collection by ID

Dim idWidget As IWidget = OperationsDashboard.Instance.Widgets.Where(Function(w) w.Id = knownIdString).FirstOrDefault()

How to find all widgets of a specific Type

To get references all widgets of a specific Type, use the OfType Linq extension method and the Widgets collection property on the OperationsDashboard class.

Find all widgets of Type

IEnumerable<IWidget> myWidgets = OperationsDashboard.Instance.Widgets.OfType<ConceptualExamples>();

Find all widgets of Type

Dim myWidgets As IEnumerable(Of IWidget) = OperationsDashboard.Instance.Widgets.OfType(Of ConceptualExamples)()

How to find the widget that provides a specific data source

To find the widget which is providing a specific data source,

Find data source provider widget

IWidget dataSourceWidget = OperationsDashboard.Instance.FindWidget(aDataSource);

Find data source provider widget

Dim dataSourceWidget As IWidget = OperationsDashboard.Instance.FindWidget(aDataSource)

Some widgets may provide a data source by consuming another data source that is in turn ultimately based on a feature layer in a map widget. To find the ultimate MapWidget that contains the layer that a data source is based upon, use the static FindMapWidget method on the MapWidget class.

Find map widget containing ultimate feature layer underlying a data source

MapWidget dataSourceMapWidget = MapWidget.FindMapWidget(aDataSource);

Find map widget containing ultimate feature layer underlying a data source

Dim dataSourceMapWidget As MapWidget = MapWidget.FindMapWidget(aDataSource)

In both cases above, if the method call returns null (Nothing in Visual Basic), then the data source is a standalone one.

1/27/2015