WPF forcing redraw of canvas

ohmusama picture ohmusama · May 11, 2011 · Viewed 57.3k times · Source

Okay, in windows forms you can use .refresh() to cause a redraw event on an element. Is there a similar solution in WPF?

An explanation of what I'm doing, I'm drawing a maze on a canvas object, and would like to watch as the maze is drawn (so I can see progress) instead of waiting 28 min for a solution to suddenly appear. I am drawing blocks on the canvas with a series of Rectangles. Should the refresh be on the rectangle or the canvas?

Here is a recent output: http://imgur.com/ftFOv

I'd like a solution in c# if that is possible. Thanks.

Answer

Adam picture Adam · Mar 22, 2012

This is what you are looking for...

element.InvalidateVisual();