XbimWindowsUI icon indicating copy to clipboard operation
XbimWindowsUI copied to clipboard

DrawingControl3D - SelectedEntityChanged RoutedEvent

Open dbalogh78 opened this issue 1 year ago • 1 comments

I've seen, that the Event SelectedEntityChangedEvent is called inside the setter of the SelectedEntity dp. It will be fired before the value actually gets set. Therefore when subscribing to the Event the SelectedEntity is not set at the moment of handling the event, so I can't interact with the SelectedEntity (getting Properties, etc.). Is this by purpose? I mean the the Event-Name implies, the property has already been changed at this moment, doesn't it? Sure I can solve this by some workaround, just were curios about the reason for the decision.

dbalogh78 avatar Apr 17 '23 08:04 dbalogh78

Hi, you want use somting like this ? ` private void DrawingControl_SelectedEntityChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) {

  if (DrawingControl.SelectedEntity == null || DrawingControl.Selection == null || DrawingControl.Selection.Count() <= 0) return;
  IPersistEntity persistEntity = DrawingControl.Selection.First();
  if (persistEntity == null) return;
  if (_currentEntity != null)
  {
      if ( _currentEntity.EntityLabel == persistEntity.EntityLabel)
      {
          return;
      }
  }
  SpatialControl.ScrollIntoView(persistEntity);
  SpatialControl.SelectedEntity = persistEntity;
  e.Handled = true;

}`

fullflash13 avatar Jan 04 '24 15:01 fullflash13