Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Avalonia TabControl causes MainSceneView to be disposed
#2
Thank you for preparing a sample app that reproduces the issue. This way I was very quickly able to reproduce the problem and find the fix.

In your app the SharpEngineSceneView control is being disposed because in the _3DControl you have the following line:

this.Unloaded += (sender, args) => MainSceneView.Dispose();

This means that if the  _3DControl is hosted in a TabControl and if the tab that shows the  _3DControl is changed, then the SharpEngineSceneView is disposed. So the next time the tab is opened, you have a disposed  SharpEngineSceneView that cannot be used anymore.

If you just comment out this line, the app will start working.

But a better option is to provide a Dispose method in the  _3DControl. There you dipose the MainSceneView. That Dispose method can be called the parent MainWindow is Unloaded - so when you close the window, you can dispose the SharpEngineSceneView because it will not be used anymore.
Andrej Benedik
  


Messages In This Thread
RE: Avalonia TabControl causes MainSceneView to be disposed - by abenedik - 02-09-2026, 08:57 AM

Forum Jump:


Users browsing this thread:
1 Guest(s)