Commit 234e9b5e authored by 潘栩锋's avatar 潘栩锋 🚴

解决了问题。 手动断开 DataLabelViewModel 与 ContentControl 的联系。 让GC可以释放

parent 176bb4df
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
<TextBlock Text="运行中"/> <TextBlock Text="运行中"/>
<TextBlock Text="{Binding IsRunning,Mode=OneWay}"/> <TextBlock Text="{Binding IsRunning,Mode=OneWay}"/>
</StackPanel> </StackPanel>
<Button Content="Update" Width="80" Padding="5" Click="Button_Click"/> <Button Content="定时更新" Width="80" Padding="5" Click="Button_Click"/>
<Button Content="清空" Width="80" Padding="5" Click="ButtonClear_Click"/>
<Button Content="GC" Width="80" Padding="5" Click="ButtonGC_Click"/> <Button Content="GC" Width="80" Padding="5" Click="ButtonGC_Click"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
......
...@@ -46,6 +46,12 @@ namespace WpfApp1 ...@@ -46,6 +46,12 @@ namespace WpfApp1
{ {
GC.Collect(); GC.Collect();
} }
private void ButtonClear_Click(object sender, RoutedEventArgs e)
{
viewModel.BoltValues.Clear();
}
} }
public class ColumnRangeExampleViewModel : INotifyPropertyChanged public class ColumnRangeExampleViewModel : INotifyPropertyChanged
{ {
...@@ -61,8 +67,8 @@ namespace WpfApp1 ...@@ -61,8 +67,8 @@ namespace WpfApp1
List<double> datas = new List<double>(); List<double> datas = new List<double>();
List<Bolt> boltmap = new List<Bolt>(); List<Bolt> boltmap = new List<Bolt>();
ChartValues<BoltValue> BoltValues = new ChartValues<BoltValue>(); public ChartValues<BoltValue> BoltValues = new ChartValues<BoltValue>();
ChartValues<double> Values = new ChartValues<double>(); public ChartValues<double> Values = new ChartValues<double>();
...@@ -178,7 +184,7 @@ Configuration = Mappers.Weighted<BoltValue>() ...@@ -178,7 +184,7 @@ Configuration = Mappers.Weighted<BoltValue>()
Update(); Update();
timer = new DispatcherTimer(); timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1); timer.Interval = TimeSpan.FromSeconds(0.1);
timer.Tick += Timer_Tick; timer.Tick += Timer_Tick;
} }
public void Start() public void Start()
......
...@@ -183,6 +183,9 @@ namespace LiveCharts.Wpf.Points ...@@ -183,6 +183,9 @@ namespace LiveCharts.Wpf.Points
chart.View.RemoveFromDrawMargin(HoverShape); chart.View.RemoveFromDrawMargin(HoverShape);
chart.View.RemoveFromDrawMargin(Rectangle); chart.View.RemoveFromDrawMargin(Rectangle);
chart.View.RemoveFromDrawMargin(DataLabel); chart.View.RemoveFromDrawMargin(DataLabel);
//feng
DataLabel.Content = null;
} }
public override void OnHover(ChartPoint point) public override void OnHover(ChartPoint point)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment