xBimTeam / XbimWindowsUI

The home of XbimXplorer and WPF components for your desktop BIM applications.
Other
252 stars 149 forks source link

DrawingControl3D - SelectedEntityChanged RoutedEvent #204

Open dbalogh78 opened 1 year ago

dbalogh78 commented 1 year ago

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.

fullflash13 commented 9 months ago

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;

}`