(Syncfusion) After SfChart recieves the second Data Object via Data Binding I get an ERROR: System.NullReferenceException

(Syncfusion) After SfChart recieves the second Data Object via Data Binding I get an ERROR: System.NullReferenceException

我有一个 MVVMCross 应用程序(Android 目前只有),我正在使用 Syncfusion 来呈现一些数据。数据 Class 有一个日期时间 属性 和一个双精度 属性。 Data Class 正确接收它的值并将它们添加到列表中,视图可以通过 DataBinding 访问它们。带有 DataBinding 的视图和图表如下所示:

 <StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
                <sfChart:SfChart HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" >

                    <sfChart:SfChart.Legend>
                        <sfChart:ChartLegend />
                    </sfChart:SfChart.Legend>

                    <sfChart:SfChart.Title>
                        <sfChart:ChartTitle Text="Daten lesen" />
                    </sfChart:SfChart.Title>

                    <sfChart:SfChart.PrimaryAxis>
                        <sfChart:DateTimeAxis>
                            <sfChart:DateTimeAxis.Title>
                                <sfChart:ChartAxisTitle Text="Zeitpunkt" />
                            </sfChart:DateTimeAxis.Title>
                        </sfChart:DateTimeAxis>
                    </sfChart:SfChart.PrimaryAxis>

                    <sfChart:SfChart.SecondaryAxis>
                        <sfChart:NumericalAxis>
                            <sfChart:NumericalAxis.Title>
                                <sfChart:ChartAxisTitle Text="Wert" />
                            </sfChart:NumericalAxis.Title>
                        </sfChart:NumericalAxis>
                    </sfChart:SfChart.SecondaryAxis>

                    <sfChart:SfChart.Series>
                        <sfChart:LineSeries ItemsSource="{Binding ChartCurrentData.ChartDataLog}" XBindingPath="DateTimeValue" YBindingPath="Value">
                        </sfChart:LineSeries>
                    </sfChart:SfChart.Series>
                </sfChart:SfChart>
            </StackLayout>

数据在此 属性 中的 ViewModel 中表示:

private ChartData _chartCurrentData;
 public ChartData ChartCurrentData { get { return _chartCurrentData; } set { _chartCurrentData = value; RaisePropertyChanged(() => ChartCurrentData); } }

ChartData 是一个 class,它存储具有 2 个属性的 DataLog (ChartDataLog) 列表:DateTime DateTimeValue 和 double Value。

图表本身在我访问它时显示得很好,在第一个值通过 Eventhandler 和 MvxNotifyProprtyChanged 发送后帮助图表轴值适应正确的范围(以及日期)但是在出现以下错误时发送第二个值:

Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
 at Mono.Debugging.VisualStudio.ExceptionsAdapter.OnUnhandledException(Object sender, TargetEventArgs args) in E:\A_work39\s\src\Debugging.VisualStudio.Vsix\Integration\ExceptionsAdapter.cs:line 71
 at Mono.Debugging.Client.DebuggerSession.OnTargetEvent(TargetEventArgs args) in E:\A_work39\s\external\debugger-libs\Mono.Debugging\Mono.Debugging.Client\DebuggerSession.cs:line 1143
 at Mono.Debugging.Soft.SoftDebuggerSession.HandleBreakEventSet(Event[] es, Boolean dequeuing) in E:\A_work39\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerSession.cs:line 1906
 at Mono.Debugging.Soft.SoftDebuggerSession.HandleEventSet(EventSet es) in E:\A_work39\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerSession.cs:line 1589
 at Mono.Debugging.Soft.SoftDebuggerSession.EventHandler() in E:\A_work39\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerSession.cs:line 1489

我已经尝试了很多事情,所以我什至不知道从哪里开始,所以对此的任何建议想法都已经足够帮助 =) 提前致谢

想通了。必须通过 UI-Thread...

添加它