Telerik图表-共享的垂直轴抛出“元素已经是另一个元素的子元素”

时间:2019-04-09 20:28:10

标签: xaml uwp telerik telerik-charting

简单的UWP应用,带有Telerik图表:

xmlns:tc="using:Telerik.UI.Xaml.Controls.Chart"
xmlns:tc1="using:Telerik.Charting"


<tc:RadCartesianChart >
 <tc:RadCartesianChart.Resources>
  <tc:LinearAxis x:Key="additionalVerticalAxis" HorizontalLocation="Right" />
 </tc:RadCartesianChart.Resources>

<tc:RadCartesianChart.HorizontalAxis>
    <tc:CategoricalAxis />
</tc:RadCartesianChart.HorizontalAxis>

<tc:RadCartesianChart.VerticalAxis>
    <tc:LinearAxis Maximum="100" Foreground="Magenta" />
</tc:RadCartesianChart.VerticalAxis>

<tc:RadCartesianChart.Series>
    <tc:BarSeries VerticalAxis="{StaticResource additionalVerticalAxis}">
        <tc:BarSeries.DataPoints>
            <tc1:CategoricalDataPoint Value="50"/>
            <tc1:CategoricalDataPoint Value="20"/>
            <tc1:CategoricalDataPoint Value="60"/>
        </tc:BarSeries.DataPoints>
    </tc:BarSeries>
    <tc:BarSeries VerticalAxis="{StaticResource additionalVerticalAxis}">
        <tc:BarSeries.DataPoints>
            <tc1:CategoricalDataPoint Value="34"/>
            <tc1:CategoricalDataPoint Value="28"/>
            <tc1:CategoricalDataPoint Value="54"/>
        </tc:BarSeries.DataPoints>
    </tc:BarSeries>
    <tc:LineSeries StrokeThickness="2" Stroke="Magenta">
        <tc:LineSeries.DataPoints>
            <tc1:CategoricalDataPoint Value="40"/>
            <tc1:CategoricalDataPoint Value="30"/>
            <tc1:CategoricalDataPoint Value="50"/>
        </tc:LineSeries.DataPoints>
    </tc:LineSeries>
</tc:RadCartesianChart.Series>
</tc:RadCartesianChart>

这是来自official (WPF) docs(“共享垂直轴”部分)的示例。应用在运行期间失败,并显示错误:

{Windows.UI.Xaml.UnhandledExceptionEventArgs}
Exception: {System.Exception: No installed components were detected.

Element is already the child of another element.
at System.Runtime.InteropServices.WindowsRuntime.IVector`1.Append(T value)
at System.Runtime.InteropServices.WindowsRuntime.VectorToCollectionAdapter.Add[T](T item)
at Telerik.UI.Xaml.Controls.Chart.RadChartBase.OnPresenterAdded(ChartElementPresenter presenter)
at Telerik.UI.Xaml.Controls.Chart.CartesianSeries.OnAttached()
at Telerik.UI.Xaml.Controls.Chart.ChartElementPresenter.Attach(RadChartBase chartBase)
at Telerik.UI.Xaml.Controls.Chart.RadChartBase.ApplyTemplateCore()
at Telerik.UI.Xaml.Controls.RadControl.OnApplyTemplate()
at Windows.ApplicationModel.Core.UnhandledError.Propagate()

...

这是怎么了?如何在多个系列之间共享轴?

0 个答案:

没有答案