title: Silverlight 5: GraphicsDevice is always null
body: <p>I am developing 3D applications using Silverlight 5.0.</p>
  
  <p>For me <code>System.Windows.Graphics.GraphicsDeviceManager.Current.GraphicsDevice</code> is always showing <code>null</code>.</p>
  
  <p>Here is my code</p>
  
  <pre><code>private void DrawingSurface_Loaded(object sender, RoutedEventArgs e)
      {
          if (GraphicsDeviceManager.Current.RenderMode != RenderMode.Hardware)
          {
              if (GraphicsDeviceManager.Current.RenderModeReason == RenderModeReason.SecurityBlocked)
              {
                  throw new  Exception();
              }
          }
  
  
          GraphicsDevice device = System.Windows.Graphics.GraphicsDeviceManager.Current.GraphicsDevice;
  
          _vertexBuffer = StreamHelper.ToMesh(device, "cube.obj");
  
          _effect = new BasicEffect(GraphicsDeviceManager.Current.GraphicsDevice);
          _effect.Texture = StreamHelper.ToTexture2D(device, "Tulips.jpg");
          _effect.TextureEnabled = true;
          _effect.World = Matrix.Identity;
          _effect.View = Matrix.CreateLookAt(new Vector3(5.0f, 5.0f, 5.0f), Vector3.Zero, Vector3.Up);
          _effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, 1.667f, 1.0f, 10.0f);
      }
  </code></pre>
  
  <p>Can anybody help me in this.</p>