int selectedCount; // Variable to keep track of the selection count in FeatureLayer public YourUserControlClassConstructor() { InitializeComponent(); FeatureLayer featureLayer = MyMap.Layers["MyFeatureLayer"] asFeatureLayer; featureLayer.Graphics.CollectionChanged += Graphics_CollectionChanged; selectedCount = featureLayer.SelectionCount; } privatevoid Graphics_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { if (selectedCount == 0 /* No selections before */ && MyDataGrid.SelectedItems.Count == 1 /* Unwanted selection after the change in graphics collection */) MyDataGrid.SelectedItems.Clear(); selectedCount = MyDataGrid.SelectedItems.Count; }
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.