MarksTip Causing Exception in WPF

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Freddie
Newbie
Newbie
Posts: 13
Joined: Thu Jun 25, 2009 12:00 am

MarksTip Causing Exception in WPF

Post by Freddie » Wed Jan 27, 2010 10:37 am

Hi,

I am using TChart (from the install) TeeChartNET2009VSNET2005WPF to graph data.
In my graph I am using the MarksTip functionality to edit the toop tip text.

It seems to be working but occassionally, when switching between windows and coming back to the graph, I get an exception.
The stack trace indicates it is a MarksTip error. See below for stack Trace.
I don't believe the GetText handler causes the problem , but it is more to do with the Logical Parent of the tooltip window.

I have managed to reproduce the problem with a miniture program. See attached zip (TChartMarksTip.zip)
To reproduce the error regularly You need to follow the following sequence.
Put a breakpoint in the GetText handler.

Then, run the program.
Press the button to create a graph.
Hover over the line to bring up a tool tip and this will switch to your Microsoft debugger.
Continue debugging F5
Hover over the graph again (away from the line) - here you will see a tiny white square and shadow - like the tool tip is blank.
Then quickly hover over the line again.
It breaks into your debugger
continue F5
and then you see the exception.

I couldn't see anyone with this problem on this forum but I have seen similar errors on other GUI libraries.
Would you be able to have a look and let me know if you can reproduce and find a workaround/fix please?

Many Thanks
Paul


Stack Trace

Code: Select all

System.InvalidOperationException: Specified element is already the logical child of another element. Disconnect it first.
   at System.Windows.FrameworkElement.ChangeLogicalParent(DependencyObject newParent)
   at MS.Internal.FrameworkObject.ChangeLogicalParent(DependencyObject newParent)
   at System.Windows.FrameworkElement.AddLogicalChild(Object child)
   at System.Windows.Controls.ContentControl.OnContentChanged(Object oldContent, Object newContent)
   at System.Windows.Controls.ContentControl.OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
   at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp)
   at System.Windows.Data.BindingExpression.Invalidate(Boolean isASubPropertyChange)
   at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
   at System.Windows.Data.BindingExpression.ScheduleTransfer(Boolean isASubPropertyChange)
   at MS.Internal.Data.ClrBindingWorker.NewValueAvailable(Boolean dependencySourcesChanged, Boolean initialValue, Boolean isASubPropertyChange)
   at MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
   at MS.Internal.Data.PropertyPathWorker.OnDependencyPropertyChanged(DependencyObject d, DependencyProperty dp, Boolean isASubPropertyChange)
   at MS.Internal.Data.ClrBindingWorker.OnSourceInvalidation(DependencyObject d, DependencyProperty dp, Boolean isASubPropertyChange)
   at System.Windows.Data.BindingExpression.HandlePropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
   at System.Windows.Data.BindingExpression.OnPropertyInvalidation(DependencyObject d, DependencyPropertyChangedEventArgs args)
   at System.Windows.DependentList.InvalidateDependents(DependencyObject source, DependencyPropertyChangedEventArgs sourceArgs)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at System.Windows.Controls.ToolTipService.SetToolTip(DependencyObject element, Object value)
   at Steema.TeeChart.WPF.Chart.ChartToolTip.Show()
   at Steema.TeeChart.WPF.Tools.MarksTip.MouseEvent(MouseEventKinds kind, MouseEventArgs e, Cursor& c)
   at Steema.TeeChart.WPF.Chart.BroadcastMouseEvent(MouseEventKinds kind, MouseEventArgs e, Cursor& c)
   at Steema.TeeChart.WPF.Chart.BroadcastMouseEvent(MouseEventKinds kind, MouseEventArgs e, ModifierKeys modKeys, Cursor& c)
   at Steema.TeeChart.WPF.TChart.OnMouseMove(MouseEventArgs e)
   at System.Windows.UIElement.OnMouseMoveThunk(Object sender, MouseEventArgs e)
   at System.Windows.Input.MouseEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at Freddie.App.Main()
Attachments
TChartMarksTip.zip
project
(22.77 KiB) Downloaded 386 times

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: MarksTip Causing Exception in WPF

Post by Sandra » Thu Jan 28, 2010 10:02 am

Hello Freddie,

I could reproduce your problem, and I have added in list of Bug Report with number [TW16014659] We will try to fix for next versions of TeeChartWPF.


Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Freddie
Newbie
Newbie
Posts: 13
Joined: Thu Jun 25, 2009 12:00 am

Re: MarksTip Causing Exception in WPF

Post by Freddie » Tue Mar 02, 2010 9:05 am

Thanks for your reply.

Do you know if this has been fixed in version 4.0.2009.62332.

Kind Regards
Freddie

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: MarksTip Causing Exception in WPF

Post by Narcís » Tue Mar 02, 2010 9:11 am

Hi Freddie,

According to the release notes in latest TeeChart for .NET 2009 maintenance release announcement, this has not been fixed yet. I recommend you to be aware at next releases announcements for what has been fixed.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Freddie
Newbie
Newbie
Posts: 13
Joined: Thu Jun 25, 2009 12:00 am

FIX: Re: MarksTip Causing Exception in WPF

Post by Freddie » Thu Mar 11, 2010 11:33 am

I managed to find a workaround so that the markstip does not crash.
The cause of the problem is that when a tooltip is active - a second tooltip can get created (under certain circumstances when you leave the window and enter it again.) This causes a logicalparent exception based on the fact that the original tooltip is still the child of the window when the second tooltip is created.

To get around this - you can remove any existing tooltips using the mouseenter event and setting the tooltip to null.

E.g.

Code: Select all

<my:TChart Name="tChart1" MouseEnter="tChart1_MouseEnter">
        </my:TChart>

Code: Select all

        private void tChart1_MouseEnter(object sender, MouseEventArgs e)
        {
            object obj = this.tChart1.ToolTip;
            if (obj != null)
            {
                this.tChart1.ToolTip = null;
            }
        }

Hope this helps.

Regards
Freddie

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: MarksTip Causing Exception in WPF

Post by Yeray » Fri Mar 12, 2010 3:30 pm

Hi Freddie,

Thanks for the feedback, we hope it will be helpful for other users.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: MarksTip Causing Exception in WPF

Post by Sandra » Wed Apr 07, 2010 11:46 am

Hello Freddie,

I communicate that we considerate bug (TW16014659) not a TeeChart.Net bug, because If it was a problem with the TeeChart code, then it could be reproduced outside of the VS Debugger and it doesn't occurs.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply