I want to refresh canvas in Windows Phone. I already have written code to remove the element from the array when the user touches the corresponding line. Now I want to remove the line, for which I have used the array, but the problem is that the line doesn't get erased. I think the code I have written is correct, but the problem is that I am not getting the function called in Silverlight or C#, which refreshes the canvas, as in Android or Java:
public void checkIntersection()
{
for (int i = 0; i < gameData.Count(); i++)
{
for (int j = 0; j < gameData.ElementAt(i).Path.Count(); j++)
{
if (gameData.ElementAt(i).Path.Contains(new Point(selectedRow, selectedCol)))
{
int index = gameData.ElementAt(i).Path.IndexOf(new Point(selectedRow, selectedCol));
while (gameData.ElementAt(i).Path.Count() > index)
{
gameData.ElementAt(i).Path.RemoveAt(gameData.ElementAt(i).Path.Count() - 1);
}
return;
}
}
}
drawPath();
}
Silverlight doesn't have a specific function to redraw the screen - it will redraw automatically when you add a remove an element from the visual tree.
It looks like in the above example, the DrawPath function translates an array into elements on the screen. If you clear all the elements, and then redraw everything, you should see the line removed.
Greg