Search code examples
windows-phone-7canvastombstoning

wp7 silverlight canvas displays black screen after tombstoning


I have a screen in my wp7 app with only a canvas, used to display a graph.

I handle the page loaded event to draw the graph, by adding lines to the graph children, the lines are stored in a list variable in App.xaml.cs.

edit: here is my draw line function

    private void drawLine(Line line, Point start, Point end, Color color)
    {            
        line.X1 = start.X;
        line.Y1 = start.Y;

        line.X2 = end.X;
        line.Y2 = end.Y;            

        line.Stroke = new SolidColorBrush(color);

        graph.Children.Add(line);
    }

I handle the tombstoning by storing/loading the lines in the settings.

I placed a breakpoint in the page loaded method, the lines are restored correctly after tombstoning, and the lines are added to the graph canvas children, yet the canvas displays a black screen.

How do i solve this ?


Solution

  • While it's not clear from your code how you're storing or recreating the data/lines the data you store during tombstoning shoudl be a collection of objects containing the start point, end point and color.

    You should be creating new lines each time you are adding a line to your graph/canvas.