本文介绍了Win2D。触发重绘事件时保留CanvasControl的旧图形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
简单示例
C#
void canvasControl_Draw (CanvasControl发送者,CanvasDrawEventArgs args)
{
var rnd = new Random(DateTime.Now.Millisecond);
args.DrawingSession.DrawEllipse((byte)rnd.Next(150),(byte)rnd.Next(100),(byte)rnd.Next(150),30,Colors.Red,3);
canvasControl.Invalidate();
}
Xaml
< canvas:CanvasControl x:Name =" canvasControl" Grid.Row = QUOT 1 QUOT; Draw =" canvasControl_Draw" />
每个新的Draw事件CanvasControl清晰图像。我需要保留图表的旧数据。如何避免每次清除CanvasControl并在示例中看到许多省略号?
解决方案
Simple example
C#
void canvasControl_Draw(CanvasControl sender, CanvasDrawEventArgs args) { var rnd = new Random(DateTime.Now.Millisecond); args.DrawingSession.DrawEllipse((byte)rnd.Next(150), (byte)rnd.Next(100), (byte)rnd.Next(150), 30, Colors.Red, 3); canvasControl.Invalidate(); }
Xaml
<canvas:CanvasControl x:Name="canvasControl" Grid.Row="1" Draw="canvasControl_Draw"/>
Every new Draw event CanvasControl clear image. I need to keep old data for charts.How to avoid of clearing CanvasControl every time and see many ellipses in the example?
解决方案
这篇关于Win2D。触发重绘事件时保留CanvasControl的旧图形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!