0

我目前正在使用折线图(来自 WinRT XAML 工具包),我遇到了一个问题:一切正常,但如果绑定到我的 LineSeries 的 (In)DependentValue 包含更改通知 (INotifyPropertyChanged),则工具包引发 COMException。

我使用了 Nuget 工具包的最新版本(1.4.1)。

我的 XAML 代码:

<toolkitchart:Chart x:Name="AltitudeChart" Height="200">
  <toolkitchart:LineSeries
    IndependentValueBinding="{Binding Distance}"
    DependentValueBinding="{Binding Distance}"
    IsSelectionEnabled="True"
    DependentRangeAxis="{Binding ElementName=LeftAxis}"
    IndependentAxis="{Binding ElementName=BottomAxis}">
    <toolkitchart:LineSeries.DataPointStyle>
       <Style TargetType="toolkitchart:LineDataPoint">
         <Setter Property="Template">
           <Setter.Value>
             <ControlTemplate>
               <local:DetailedPushpin ManipulationDelta="DetailedPushpin_ManipulationDelta" ManipulationMode="TranslateY"/>
             </ControlTemplate>
           </Setter.Value>
         </Setter>
       </Style>              
    </toolkitchart:LineSeries.DataPointStyle>
  </toolkitchart:LineSeries>
  <toolkitchart:Chart.Axes>
    <toolkitchart:LinearAxis x:Name="RightAxis" Orientation="Y" Location="Right"/>
    <toolkitchart:LinearAxis x:Name="LeftAxis" Orientation="Y" Location="Left" Foreground="White"/>
    <toolkitchart:LinearAxis x:Name="BottomAxis" Orientation="X" Location="Bottom" Foreground="White"/>
  </toolkitchart:Chart.Axes>
</toolkitchart:Chart>

还有我的 C# 代码:

ObservableCollection<AltChartPoint> ChartPoints = new  ObservableCollection<AltChartPoint>();
AltChartPoint a = new AltChartPoint(12); 
ChartPoints.Add(a);
a.Distance = 13; <-- Throw exception if the change is notified

...

public class AltChartPoint : INotifyPropertyChanged
{
  private double _distance;
  public double Distance 
  {
    get { return _distance; }
    set
    {
      _distance = value;
      //NotifyPropertyChanged("Distance"); <-- Problem is here
    }
  }
}

是否可以通过通知属性更新来更新图表?

请注意,如果我尝试直接编辑 LineDataPoint.DependentValue,则会发生相同的异常

4

0 回答 0