I will try to write a really helpful blog post ;-). Here are few tips in advance off the top of my head:
In the constructor always set a style name
Style = "TexturedProgressBar";
This is only needed if you want to style the control in the Theme.xml. Nevertheless it is good practice to always set a unique style name.
In OnRender the control has to be drawn everytime - no matter what IsVisualValid says. In OnRender you can cache information and you can assume that this information is valid as long as IsVisualValid is true. For example:
protected override void OnRender(float deltaTime)
//Do complex precomputation and cache results.
// Render using cached information.
IsVisualValid is automatically reset when a control property is changed that influences the visual appearance. IsVisualValid is automatically set to true after OnRender() was called.
If you have a very complex control, you could, for example, draw you control into a texture if IsVisualValid is false - but you still have to copy this cached texture to the screen every time OnRender() is called.
base.OnRender() calls the normal Screen.Renderer.Render() method which draws the control based on its style. If you do all the dawing yourself, then you should skip this call.
If you want to be able to animate your control (using properties like control.RenderTranslation, as in the UIAnimationSample), then you also have to consider the RenderTransform of your control - but I would ignore this for now.
When creating a new custom control, overriding OnRender() is the simplest method, and I would start this way.
A more advanced way to implement custom drawing is to not override OnRender and instead to add a new RenderCallback for the style "TexturedProgresBar" to the UIRenderer. If you are interested in this method, check out UIRenderer_Render.cs in the DigitalRune.Game.UI source code - or wait for the blog posts ;-)
I will write blog posts with more details. Maybe I will show how to develop a new control step-by-step. Any suggestions which type of control I should develop? Is there a missing control type desperately needed by anyone?