在 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() 之后加载新系列时,渲染的图像都会一次又一次地移位......
我希望有一个人可以帮助我。谢谢!