I am building a 3D application with Silverlight 5. I have a DrawingSurface which calls a method. However, when I add a navigation:Frame to my XAML, I then get an error thrown.
Here is the method in question:
private void DrawingSurface_Draw(object sender, DrawEventArgs e)
{
    GraphicsDevice device = GraphicsDeviceManager.Current.GraphicsDevice;
    device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer,
                 new Microsoft.Xna.Framework.Color(0, 0, 0, 0), 10.0f, 0);
    device.SetVertexBuffer(_vertexBuffer);
    device.SetVertexShader(_vertexShader);
    device.SetPixelShader(_pixelShader);
    device.Textures[0] = _texture;
    device.SamplerStates[0] = SamplerState.LinearClamp;
    device.DrawPrimitives(PrimitiveType.TriangleList, 0,
                          _vertexBuffer.VertexCount / 3);
    device.SetVertexShaderConstantFloat4(0, ref _viewProjection);
    e.InvalidateSurface();
}
The error is at the line device.DrawPrimitives(PrimitiveType.TriangleList, 0, _vertexBuffer.VertexCount / 3); . The error is that "NullReferenceException was unhandled by user code." It does not occur without the navigation:Frame.
 
     
    