SciChart 在插入新轴时抛出异常

SciChart throws an exception on new axis insertion

我有两个 AxisCollection

    private AxisCollection _xAxes = new AxisCollection();
    public AxisCollection XAxes
    {
        get => _xAxes;
        set 
        {
            _xAxes = value;
            OnPropertyChanged("XAxes");
        }
    }

    private AxisCollection _yAxes = new AxisCollection();
    public AxisCollection YAxes
    {
        get => _yAxes;
        set
        {
            _yAxes = value;
            OnPropertyChanged("YAxes");
        }
    }

两者分别绑定到 SciChartSurfaceXAxesYAxes:

        <s:SciChartSurface Grid.Row="0"
                       Grid.RowSpan="3"
                       Grid.Column="0"
                       Grid.ColumnSpan="2"
                       Panel.ZIndex="0"
                       RenderableSeries="{Binding RenderableSeries}"  
                       ChartTitle="{Binding ChartTitle}"
                       XAxes="{Binding XAxes}"
                       YAxes="{Binding YAxes}">

我尝试使用以下方法添加轴:

        public void AddAxes()
    {
        XAxes.Add(new NumericAxis() { AxisTitle = "X Achse"});
        XAxes.Add(new NumericAxis() { AxisTitle = "X Achse 2" });
        YAxes.Add(new NumericAxis() { AxisTitle = "Y Achse", AxisAlignment = AxisAlignment.Left});
    }

添加第二个X轴导致异常:

"SciChartSurface 没有呈现,因为抛出了异常: 消息:Ein Element mit dem gleichen Schlüssel wurde bereits hinzugefügt.

什么意思"An item with the same key has already been added"。我假设(虽然不确定)它发生是因为所有创建的轴都具有相同的 x:Key.

我该如何解决这个问题?

为每个轴添加唯一 ID 解决了问题:

    public void AddAxes()
    {
        XAxes.Add(new NumericAxis() { Id = "1", AxisTitle = "X Achse"});
        XAxes.Add(new NumericAxis() { Id = "2", AxisTitle = "X Achse 2" });
        YAxes.Add(new NumericAxis() { AxisTitle = "Y Achse", AxisAlignment = AxisAlignment.Left});
    }