Search code examples
.netwindows-phone-8teechart

teechart zoom & scroll on windows phone 8


In a windows phone 8 project I'm creating a TChart inside a UserControl like this:

    Chart.Legend.LegendStyle = LegendStyles.Series;
    Chart.Legend.Alignment = LegendAlignments.Bottom;
    Chart.Header.Visible = false;

    if (Page.ZoomMode)
    {
        Chart.Aspect.GestureOptions = Steema.TeeChart.Silverlight.Drawing.Aspect.Gestures.PinchAndDrag;
        Chart.Aspect.GestureStyle = Steema.TeeChart.Silverlight.Drawing.Aspect.GestureStyles.FullChart;
    }
    else
    {
        Chart.Aspect.GestureOptions = Steema.TeeChart.Silverlight.Drawing.Aspect.Gestures.None;
        Chart.Aspect.GestureStyle = Steema.TeeChart.Silverlight.Drawing.Aspect.GestureStyles.InChart;
    }

    var theme = ThemeManager.GetDefaultTChartTheme(Chart.Chart);
    theme.Apply();

The UserControl is inside a PivotItem. The idea is to lock the pivot while in zoom mode to allow the Chart to respond to drag & pinch gestures.

Problem 1: Changing dynamically Chart.Aspect.GestureStyle and Chart.Aspect.GestureOptions after a first draw launches this exception:

System.InvalidOperationException: Element is already the child of another element.
   at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.Collection_AddValue[T](PresentationFrameworkCollection`1 collection, CValue value)
   at MS.Internal.XcpImports.Collection_AddDependencyObject[T](PresentationFrameworkCollection`1 collection, DependencyObject value)
   at System.Windows.PresentationFrameworkCollection`1.AddDependencyObject(DependencyObject value)
   at System.Windows.Controls.UIElementCollection.AddInternal(UIElement value)
   at System.Windows.PresentationFrameworkCollection`1.Add(T value)
   at Steema.TeeChart.Silverlight.Drawing.TBlockCanvas.ShowImage()
   at Steema.TeeChart.Silverlight.TChart.Draw(Rect rect)
   at Steema.TeeChart.Silverlight.TChart.MeasureOverride(Size availableSize)
   at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Double inWidth, Double inHeight, Double& outWidth, Double& outHeight)

Problem 2: If the first draw is with zoom enabled. After locking the pivot all seems to work, I can drag the chart on the screen. But everytime I load new series after a tChart.Series.Clear() the rendered image displaces again and again...

I hope someone can help me. Thank you!


Solution

  • Which version of TeeChart.Phone.dll are you using?

    Using Steema TeeChart for .NET 2013 Evaluation 4.1.2013.07304 I've just run the following project: Steema TeeChart for .NET 2013 Evaluation 4.1.2013.07304\Examples\DemoProjectWindowsPhone\TeeChartForWindowsPhone.csproj

    which under "settings" allows one to successfully change the Aspect.GestureStyle dynamically. Can you please look at this project for assistance? If you still have problems, can you please send us a small "stand alone" project with which we can reproduce the problem? You can either post your files at www.steema.net/upload/ or send them to info at steema dot com referencing this question.

    UPDATE: Using your sample project, we've been able to reproduce his problem here. Unfortunately, the only solution at the moment for these two properties (GestureOptions & GestureStyle) is to recreate the chart, that is, to create a new instance of the TChart class, as the demo does. Other chart properties, adding and deleting series, adding and deleting series points, axis font changes and what have you, can be changed without a problem after the TChart class has been created. But the situation is different for these two properties thanks to the structural changes they have to make to the TChart architecture.

    We'll look further into making such changes possible, but we don't hold out a lot of hope. There seem to be some issues in the Windows Phone framework (and in the Windows Store framework, in fact) related to elements that are children of other elements, and how when the parent element has been destroyed the framework thinks the child element still belongs to it (elements can't have more than one parent).