Click or drag to resize
DigitalRuneUIControlOnRender Method
Called when the control and its visual children should be rendered.

Namespace: DigitalRune.Game.UI.Controls
Assembly: DigitalRune.Game.UI (in DigitalRune.Game.UI.dll) Version: 1.8.0.0 (1.8.0.14553)
Syntax
protected virtual void OnRender(
	UIRenderContext context
)

Parameters

context
Type: DigitalRune.Game.UI.ControlsUIRenderContext
The render context.
Remarks

The base implementation calls Render(UIControl, UIRenderContext) to let the renderer perform the drawing. This method can be overridden in derived classes to perform custom drawing using any means.

Important: If this method changes the render states or uses a sprite batch other than the SpriteBatch of the IUIRenderer, EndBatch must be called to flush the current sprite batch before custom drawing code is executed.

C#
public class CustomControl : UIControl
{
  ...

  protected override void OnRender(RenderContext context)
  {
    // Get the renderer of the screen that owns this control.
    var renderer = Screen.Renderer;

    // The renderer batches all SpriteBatch drawing calls together. Since we want to 
    // change the graphics device settings, we have to commit the current batch.
    renderer.EndBatch();

    // Do custom rendering here.
    ...
  }
}

See Also