public override Size GetPreferredSize(ViewLayoutContext context)
{
Debug.Assert(context != null);
// Validate incoming reference
if (context == null) throw new ArgumentNullException("context");
// Ensure any content children have correct composition setting
foreach (ViewBase child in this)
if (child is ViewDrawContent)
{
ViewDrawContent viewContent = (ViewDrawContent)child;
viewContent.DrawContentOnComposition = DrawCanvasOnComposition;
}
// Let base class find preferred size of the children
Size preferredSize = base.GetPreferredSize(context);
// Apply space the border takes up
if (DrawTabBorder)
preferredSize = CommonHelper.ApplyPadding(Orientation, preferredSize, context.Renderer.RenderTabBorder.GetTabBorderDisplayPadding(context, _paletteBorder, State, Orientation, TabBorderStyle));
else
preferredSize = CommonHelper.ApplyPadding(Orientation, preferredSize, context.Renderer.RenderStandardBorder.GetBorderDisplayPadding(_paletteBorder, State, Orientation));
// Do we have a metric source for additional padding?
if ((_paletteMetric != null) && (_metricPadding != PaletteMetricPadding.None))
{
// Apply padding needed outside the border of the canvas
preferredSize = CommonHelper.ApplyPadding(Orientation, preferredSize, _paletteMetric.GetMetricPadding(State, _metricPadding));
}
return preferredSize;
}