RenderSurface

Rules worth knowing

These are the operational rules that matter when you use RenderSurface in a real app.

  • Manual and managed modes are not blended. If managed mode is active, the managed presentation surface wins while it is active.
  • If managed mode later becomes inactive, the previously assigned manual surface becomes visible again.
  • Managed resources are recreated when the arranged size changes or the graphics device changes.
  • InvalidateVisual() in managed mode marks the managed surface dirty so it will be redrawn.
  • RefreshSurface() is the lightweight "redraw this surface" signal when the underlying content changed.
  • ClearSurface() clears the manually assigned surface reference.
  • OnFrameUpdate only matters in managed mode, and only when IsFrameUpdateActive returns true.

Recommended rule of thumb: if your gameplay code already produces a texture, use manual mode. If you want ad hoc drawing from a screen or view, use the DrawSurface event. If the thing you are building deserves to become a reusable control, subclass RenderSurface and own the drawing behavior there.