チャートを更新して、そこにいくつかの散布点を描画しようとしています。そのために私は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.