public override void Layout(ViewLayoutContext context)
{
Debug.Assert(context != null);
// We take on all the available display area
ClientRectangle = context.DisplayRectangle;
// Reduce our size by a padding around the element
ClientRectangle = new Rectangle(ClientLocation.X + OuterPadding.Left,
ClientLocation.Y + OuterPadding.Top,
ClientWidth - OuterPadding.Horizontal,
ClientHeight - OuterPadding.Vertical);
// Reduce again to arrive at size available for child elements
context.DisplayRectangle = new Rectangle(ClientLocation.X + LayoutPadding.Left,
ClientLocation.Y + LayoutPadding.Top,
ClientWidth - LayoutPadding.Horizontal,
ClientHeight - LayoutPadding.Vertical);
// Let contained content element we layed out
base.Layout(context);
// Put back the original display value now we have finished
context.DisplayRectangle = ClientRectangle;
}