WinrtXamlToolkit - 图表:使用INotifyPropertyChanged时的ComException

时间:2013-05-24 07:49:30

标签: c# charts windows-runtime comexception

我目前正在使用折线图(来自WinRT XAML Toolkit),我遇到了一个问题:一切顺利,但是如果绑定到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

,则会发生同样的异常

0 个答案:

没有答案