In some case, you may find out that when you call
Invalidate() method, the
Draw event will not be raised. Now if you watch the variable of
CanvasControl you can find the
Device property is throwing an
ArgumentException and of course the
Draw event will not be raised.
The source of this issue hasn't been found, but I do have a solution(or call it workaround), this workaround will be apply if you have the similar need:
You don't want to use
CanvasControlto draw sth at the first time, you want to draw it later after some logical operation.
In my case, my page will receive an image and then blur it.
Here is the workaround:
- First add the attribute of
- When you are ready to draw sth, find it and prepare resource then call
this.FindName("canvas"); //do sth canvas.Invalidate();