private Size CalculatePreferredSize()
{
// Prevent calculation of layout from performing a recursive layout
SuspendLayout();
try
{
// Find the preferred size which fits exactly the calculated contents size
using (ViewLayoutContext context = new ViewLayoutContext(this, Renderer))
return ViewManager.Root.GetPreferredSize(context);
}
finally
{
// Must always have matching suspend/resume
ResumeLayout();
}
}