Load(MapMember,Int64) Method
Load a single feature into the inspector. This method must be called on the MCT. Use QueuedTask.Run.
Get selected feature's attribute value
QueuedTask.Run(() =>
{
// get the currently selected features in the map
var selectedFeatures = ArcGIS.Desktop.Mapping.MapView.Active.Map.GetSelection();
// get the first layer and its corresponding selected feature OIDs
var firstSelectionSet = selectedFeatures.ToDictionary().First();
// create an instance of the inspector class
var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector();
// load the selected features into the inspector using a list of object IDs
inspector.Load(firstSelectionSet.Key, firstSelectionSet.Value);
//get the value of
var pscode = inspector["STATE_NAME"];
var myGeometry = inspector.Shape;
});
Read from a raster field
QueuedTask.Run(() =>
{
var sel = MapView.Active.Map.GetSelection();
//Read a raster from a raster field as an InteropBitmap
//the bitmap can then be used as an imagesource or written to disk
var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector();
insp.Load(sel.ToDictionary().Keys.First(), sel.ToDictionary().Values.First());
var ibmp = insp["Photo"] as System.Windows.Interop.InteropBitmap;
});
Write an image to a raster field
QueuedTask.Run(() =>
{
var sel = MapView.Active.Map.GetSelection();
//Insert an image into a raster field
//Image will be written with no compression
var insp = new ArcGIS.Desktop.Editing.Attributes.Inspector();
insp.Load(sel.ToDictionary().Keys.First(), sel.ToDictionary().Values.First());
insp["Photo"] = @"e:\temp\Hydrant.jpg";
var op = new EditOperation();
op.Name = "Raster Inspector";
op.Modify(insp);
op.Execute();
});
Target Platforms: Windows 11, Windows 10, Windows 8.1
ArcGIS Pro version: 2.0 or higher.