WPF Toolkit 控件 频繁产生事件PropertyChanged 造成界面卡到不动了

shizhongqi 2016-01-07 04:26:36
首先我是想用Toolkit 这个第三方控件 来显示200左右个数据曲线,x轴不变,只改变Y轴的值就可以。
发现一调用这个控件界面就会变慢。
下面我附上一些主要代码帮我看一下问题出在哪了。
逻辑.cs代码
public ObservableCollection<CellVoltageObj> cell_voltage = new ObservableCollection<CellVoltageObj>();

public class CellVoltageObj : INotifyPropertyChanged
{
private int _VoltageID;
public int VoltageID
{
get { return _VoltageID; }
set
{
_VoltageID = value;
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("VoltageID"));
}
}
}
private float _VoltageValue;
public float VoltageValue
{
get { return _VoltageValue; }
set
{
_VoltageValue = value;
if(PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs("VoltageValue"));
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
}

前端.xaml代码

<UserControl x:Class="Soaring.EMS_ZB.UserControl_CellVoltage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Charting="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" xmlns:chartingprimitives="clr-namespace:System.Windows.Controls.DataVisualization.Charting.Primitives;assembly=System.Windows.Controls.DataVisualization.Toolkit" mc:Ignorable="d"
>
<Grid>
<Charting:Chart Name="MemoryChartComponent" HorizontalAlignment="Right" Width="160" Height="75" VerticalAlignment="Top" BorderBrush="#FFD5DFE5" >
<Charting:LineSeries VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
ItemsSource="{Binding}"
IndependentValuePath="VoltageID"
DependentValuePath="VoltageValue">
<Charting:LineSeries.DataPointStyle>
<Style TargetType="Charting:LineDataPoint">
<Setter Property="Opacity" Value="0" />
<Setter Property="Background" Value="Red" />
</Style>
</Charting:LineSeries.DataPointStyle>
</Charting:LineSeries>

<Charting:Chart.Axes>
<Charting:LinearAxis Orientation="Y" ShowGridLines="False" Visibility="Hidden" Width="0" />
<Charting:DateTimeAxis Orientation="X" Visibility="Hidden" Height="0" ></Charting:DateTimeAxis>
</Charting:Chart.Axes>
<Charting:Chart.Template>
<ControlTemplate TargetType="{x:Type Charting:Chart}">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<chartingprimitives:EdgePanel Name="ChartArea" Style="{TemplateBinding ChartAreaStyle}" Grid.Row="0" Margin="0">
<Grid Panel.ZIndex="-1" Style="{TemplateBinding PlotAreaStyle}" />
<Border Panel.ZIndex="10" BorderBrush="#FF919191" BorderThickness="0" />
</chartingprimitives:EdgePanel>
</Grid>
</Border>
</ControlTemplate>
</Charting:Chart.Template>
</Charting:Chart>
</Grid>
</UserControl>

另外:INotifyPropertyChanged 接口产生事件太多会不会造成前台界面很卡,有没有优化的方法。

谢谢大家
...全文
481 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
shizhongqi 2016-01-08
  • 打赏
  • 举报
回复
自己顶一下吧,哪位大神帮帮我啊。

13,347

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 .NET技术前瞻
社区管理员
  • .NET技术前瞻社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧