SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components
Right now I’m encountering a strange problem.
The error message says “Specified element is already the logical child of another element. Disconnect it first.”
However, the problem doesn’t occur every time though.
This problem never occurs on Windows 7, and it may be related to how DataContext gets changed in newer versions of Windows (like Windows 10 and Windows Server 2012 R2) after remote login or user switch.
Here’s a link to a StackOverflow question posted by someone else regarding this DataContext issue: http://stackoverflow.com/questions/40996366/wpf-view-constructor-called-on-windows-switch-user-or-remote-desktop-login
Somehow, a DataContext change would occasionally glitch up SciChart to produce this exception. This is problematic because one of our customers installed our WPF software application (containing SciChart) on a Windows Server 2012 R2 machine, and would remote login to that machine to run the app. Occasionally the Windows Remote Desktop would lose its connection (understandable), but when the customer logs in again, if the screen the customer was on contained a SciChart surface, the app would occasionally display the InvalidOperationException and crash.
Hi Rocky
We saw a similar issue to this and it was solved in v4.2.2 nightly build of SciChart.
We also saw another (similar) issue and it was solved by changing (on the user side) how the DataContext is initialized. One customer had created DataContext in the Constructor of a UserControl. When the TabControl switched WPF destroys and recreates the UserControl. So you get new DataContext but the DataContext in their case had FrameworkElements such as Axis, Annotations, RenderableSeries in it. So they ended up with a virtualized (recycled) view – the SciChartSurface and a new instnace of ViewModel (DataContext) which had old instances of FrameworkElements in it, and … bang
So, I would suggest. Try the above. Update to the nightly. This will be official v4.2.2 very soon. If that doesn’t work then take a very close look at your DataContext. How you are creating it, and whether it contains FrameworkElements which bind to SciChartSurface. If so, please try refactoring it or playing around and see if you can find the root cause.
Best regards,
Andrew
Please login first to submit.