我正在尝试更新图表并在那里绘制一些散点。为此,我正在使用BackgroundWorker
类。它确实有效。但我注意到,一旦我向我的 Point 类添加颜色并想要显示不同颜色的点,它就会崩溃。为什么?有任何想法吗?
public class ChartData
{
private readonly Brush Red = new SolidColorBrush(Colors.Red);
private readonly Brush Orange = new SolidColorBrush(Colors.Orange);
private readonly Brush Green = new SolidColorBrush(Colors.Green);
public ChartData(double x, double y)
{
this.XValue = x;
this.YValue = y;
}
public double XValue { get; set; }
public double YValue { get; set; }
public Brush Brush{ get; set;}
}
<telerik:ScatterPointSeries XValueBinding="XValue"
YValueBinding="YValue"
ItemsSource="{Binding Data}" >
<telerik:ScatterPointSeries.PointTemplate>
<DataTemplate>
<Ellipse Width="10"
Height="10"
Fill="{Binding DataItem.Brush}"/>
</DataTemplate>
</telerik:ScatterPointSeries.PointTemplate>
</telerik:ScatterPointSeries>
例外:Must create DependencySource on same Thread as the DependencyObject.