示例#1
0
    void UpdateRenderTarget(FrameworkElement fe)
    {
      RectangleF bounds = new RectangleF(0, 0, _vertsBounds.Size.Width, _vertsBounds.Size.Height);
      fe.RenderToSurface(_visualSurface, new RenderContext(Matrix.Identity, Opacity, bounds, 1.0f));

      // Unfortunately, brushes/brush effects are based on textures and cannot work with surfaces, so we need this additional copy step
      GraphicsDevice.Device.StretchRectangle(
          _visualSurface.Surface, new Rectangle(0, 0, _visualSurface.Size.Width, _visualSurface.Size.Height),
          _visualTexture.Surface0, new Rectangle(0, 0, _visualTexture.Size.Width, _visualTexture.Size.Height),
          TextureFilter.None);
    }