请教各位前辈有关WPF相关问题,谢谢!!
还请各位大牛指导下下面两个问题,非常感谢!!!!
1. 使用的开发工具是VS 2010的WPF,基于TabControl创建了3个TabItem(分别称为T1、T2、T3),其中在T2项中创建了以
下:
<TabItem Name="RadarAScope" Header="AScope">
<Grid Name="RadarAScopeGrid"></Grid>
</TabItem>
在C#初始化流程的this.InitializeComponent();后面增加了绘制坐标系的代码
// AScope图表控件
Chart m_AScopeChart = new Chart();
// 设置RadarAScope内容
m_AScopeChart.Width = 500;
m_AScopeChart.MaxWidth = 500;
// Create a new Axis
Axis axisX = new Axis();
axisX.IntervalType = IntervalTypes.Number;
m_AScopeChart.AxesX.Add(axisX);
Axis axisY = new Axis();
axisY.IntervalType = IntervalTypes.Number;
m_AScopeChart.AxesY.Add(axisY);
m_AScopeChart.AnimationEnabled = false;
m_AScopeChart.ScrollingEnabled = false;
RadarAScopeGrid.Children.Add(m_AScopeChart);
程序运行后,默认是显示T1项,通过鼠标切换到T2,或者在其他控件按钮对T2进行Focus(),会出现短时间的卡顿,之后
再怎么切换,或者通过其他按钮激活,都不会出现卡顿现象,请问这是什么原因,如何解决??
2. 现在需要在上面的坐标系中描点画条状图,基于某个控件来激活,方式如下:
DataSeries data = new DataSeries();
int iDataNum = 2000;
for (int i = 0; i < iDataNum; ++i)
{
DataPoint tDataPoint = new DataPoint();
tDataPoint.XValue = i;
tDataPoint.YValue = 随机值;
data.DataPoints.Add(tDataPoint);
}
m_AScopeChart.Series.Add(data);
这样会阻塞UI线程的执行,尝试将上面的流程搬到后台线程,提示DataSeries不能在非UI线程中使用,请问如何解决这个画图效率问题,谢谢!!