InvalidOperationException in Steema.WPF with MarkTip

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
bc-user1
Newbie
Newbie
Posts: 1
Joined: Thu Oct 28, 2010 12:00 am

InvalidOperationException in Steema.WPF with MarkTip

Post by bc-user1 » Wed Mar 23, 2011 4:36 pm

Hello,

I am getting an intermittent InvalidOperationException when using MarkTips.

Here is the marktip creation code:

Code: Select all

var marksTip = new MarksTip();
marksTip.GetText += MarksTipGetText;
chart.Tools.Add(marksTip);
...
        private void MarksTipGetText(MarksTip sender, MarksTipGetTextEventArgs e)
        {
            e.Text = _hoveringLegend ?? string.Empty;
        }
It looks like sometimes, the chart tries to add the marktip twice and the marktip complains that it already has a logical parent.
I am using .Net 4 with TeeChart.WPF 4.0.2011.2083

Here is the full stacktrace:

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 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, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp)
   at System.Windows.Data.BindingExpressionBase.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.BindingExpressionBase.OnPropertyInvalidation(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, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, 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.RaiseTrustedEvent(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, WindowMessage 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, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

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

Re: InvalidOperationException in Steema.WPF with MarkTip

Post by Sandra » Thu Mar 24, 2011 11:12 am

Hello bc-user1,

I couldn't reproduce your problem using last version of TeeChart.Net and next code:

Code: Select all

        public MainWindow()
        {
            InitializeComponent();
            InitializeChart();
        }
        private void InitializeChart()
        {
            Steema.TeeChart.WPF.Styles.Bar bar1 = new Steema.TeeChart.WPF.Styles.Bar(tChart1.Chart);
            bar1.FillSampleValues();
            Steema.TeeChart.WPF.Tools.MarksTip marktips = new Steema.TeeChart.WPF.Tools.MarksTip(tChart1.Chart);
            bar1.Marks.Visible = false;
            marktips.GetText += new Steema.TeeChart.WPF.Tools.MarksTipGetTextEventHandler(marktips_GetText);
        }

        void marktips_GetText(Steema.TeeChart.WPF.Tools.MarksTip sender, Steema.TeeChart.WPF.Tools.MarksTipGetTextEventArgs e)
        {
            e.Text = e.Text ?? string.Empty;
        }
Could you check if in previous code appears your problem?

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