我正在使用Silverlight 5构建一个3D应用程序.我有一个调用方法的DrawingSurface.但是,当我向我的XAML添加导航:Frame时,我会抛出一个错误.
这是有问题的方法:
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),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,_vertexBuffer.VertexCount / 3); device.SetVertexShaderConstantFloat4(0,ref _viewProjection); e.InvalidateSurface(); }
错误发生在line device.DrawPrimitives(PrimitiveType.TriangleList,_vertexBuffer.VertexCount / 3); .错误是“NullReferenceException未被用户代码处理”.没有导航就不会发生:框架.