I would like to open the attribute table for a selected layer. I was able to create table from a feature layer and have access to it. However, I do not know how to put that into the display like right clicking on the layer and opening the attribute table.
public void create_Layer()
{
string shp_path = this.ComboBox_shps.Text;
int indexNumber = 0;
if (shp_path != null && shp_path != string.Empty)
{
System.Uri shp_filepath = new System.Uri(@shp_path);
QueuedTask.Run(() =>
{
var shp_layer = LayerFactory.Instance.CreateLayer(shp_filepath, MapView.Active.Map, indexNumber, shp_path.Substring(16));
//Get the active map view.
var mapView = MapView.Active;
if (mapView == null)
return Task.FromResult(false);
else
{
var selectedLayer = mapView.GetSelectedLayers()[0];
if (selectedLayer is ArcGIS.Desktop.Mapping.FeatureLayer)
{
ArcGIS.Core.Data.Table a_table = (selectedLayer as FeatureLayer).GetTable();
int gugu = a_table.GetCount();
MessageBox.Show(gugu.ToString()); // I can get the row count here
}
//Zoom to the selected layers in the TOC
return mapView.ZoomToAsync(selectedLayer);
}
});
}
}