0

在 windows phone 8 项目中,我在 UserControl 中创建了一个 TChart,如下所示:

    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();

UserControl 位于 PivotItem 内。这个想法是在缩放模式下锁定枢轴,以允许图表响应拖动和捏合手势。

问题 1:在第一次绘制后动态更改 Chart.Aspect.GestureStyle 和 Chart.Aspect.GestureOptions 会启动此异常:

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)

问题 2:如果第一次绘制启用了缩放。锁定枢轴后似乎一切正常,我可以在屏幕上拖动图表。但是每次我在 tChart.Series.Clear() 之后加载新系列时,渲染的图像都会一次又一次地移位......

我希望有一个人可以帮助我。谢谢!

4

1 回答 1

0

您使用的是哪个版本的 TeeChart.Phone.dll?

使用 Steema TeeChart 进行 .NET 2013 评估 4.1.2013.07304 我刚刚运行了以下项目: Steema TeeChart for .NET 2013 评估 4.1.2013.07304\Examples\DemoProjectWindowsPhone\TeeChartForWindowsPhone.csproj

在“设置”下,可以成功地动态更改 Aspect.GestureStyle。你能看看这个项目寻求帮助吗?如果您仍然有问题,您能否向我们发送一个小的“独立”项目,我们可以用它来重现问题?您可以在www.steema.net/upload/上发布您的文件,或者将它们发送到 steema dot com 上的 info 引用此问题。

更新:使用您的示例项目,我们已经能够在这里重现他的问题。不幸的是,目前这两个属性(GestureOptions 和 GestureStyle)的唯一解决方案是重新创建图表,即创建 TChart 类的新实例,就像演示一样。其他图表属性,添加和删除系列,添加和删除系列点,轴字体更改以及您有什么,可以在创建 TChart 类后毫无问题地更改。但是由于必须对 TChart 架构进行结构更改,这两个属性的情况有所不同。

我们将进一步研究使此类更改成为可能,但我们并不抱太大希望。Windows Phone 框架(实际上是 Windows Store 框架)中似乎存在一些与其他元素的子元素相关的问题,以及当父元素被销毁时框架如何认为子元素仍然属于它(元素不能有多个父级)。

于 2013-08-07T09:18:21.537 回答