Hi Joshua,
The way I got this to work was to create a query and iterate using a cursor. You want to make sure your query returns one feature.
////Zoom to the envelope of each feature
//Reference the layout
Layout layout = LayoutView.Active.Layout;
//Select the feature
await QueuedTask.Run(() =>
{
//Reference the mapframe, associated map, and build a query
MapFrame mf = layout.FindElement("Map Frame") as MapFrame;
Map m = mf.Map;
FeatureLayer fl = m.FindLayers("GreatLakes").First() as FeatureLayer;
QueryFilter qf = new QueryFilter();
string whereClause = "NAME = 'Lake Erie'";
qf.WhereClause = whereClause;
//Zoom to the feature
using (ArcGIS.Core.Data.RowCursor rowCursor = fl.Search(qf))
{
while (rowCursor.MoveNext())
{
// get the shape from the row
ArcGIS.Core.Data.Feature feature = rowCursor.Current as ArcGIS.Core.Data.Feature;
Polygon polygon = feature.GetShape() as Polygon;
Envelope env = polygon.Extent as Envelope;
mf.ZoomTo(env);
}
}
});
I hope this helps,
Jeff