ActivateSelectAsync Method
                In This Topic
            
            Sets the tool into or out of selection mode. Only supported when 
SketchType is set to Point, Line, Polygon, or Multipoint.
Syntax
            
        
            Parameters
- activate
- If True the tool will start selecting features.
Return Value
A Task representing the mode change operation. Returns false if the 
SketchType is unsupported.
 
            
            
            
            
            
            Example
        
      
             Toggle sketch selection mode
    
	
		//UseSelection = true; (UseSelection must be set to true in the tool constructor or tool activate)
private bool _inSelMode = false;
public bool IsShiftKey(MapViewKeyEventArgs k)
{
  return (k.Key == System.Windows.Input.Key.LeftShift ||
         k.Key == System.Windows.Input.Key.RightShift);
}
protected override async void OnToolKeyDown(MapViewKeyEventArgs k)
{
  //toggle sketch selection mode with a custom key
  if (k.Key == System.Windows.Input.Key.W)
  {
    if (!_inSelMode)
    {
      k.Handled = true;
      // Toggle the tool to select mode.
      //  The sketch is saved if UseSelection = true;
      if (await ActivateSelectAsync(true))
        _inSelMode = true;
    }
  }
  else if (!_inSelMode)
  {
    //disable effect of Shift in the base class.
    //Mark the key event as handled to prevent further processing
    k.Handled = IsShiftKey(k);
  }
}
protected override void OnToolKeyUp(MapViewKeyEventArgs k)
{
  if (k.Key == System.Windows.Input.Key.W)
  {
    if (_inSelMode)
    {
      _inSelMode = false;
      k.Handled = true;//process this one
      // Toggle back to sketch mode. If UseSelection = true
      //   the sketch will be restored
      ActivateSelectAsync(false);
    }
  }
  else if (_inSelMode)
  {
    //disable effect of Shift in the base class.
    //Mark the key event as handled to prevent further processing
    k.Handled = IsShiftKey(k);
  }
}
	 
	
 
 
            
            
            Requirements
Target Platforms: Windows 11, Windows 10, Windows 8.1
See Also