/// <summary> /// Discover the preferred size of the element. /// </summary> /// <param name="context">Layout context.</param> public override Size GetPreferredSize(ViewLayoutContext context) { // Create/delete child elements to match the current selected bread crumb path SyncBreadCrumbs(); // We need to update the redirector for drawing each crumb PaletteRedirectBreadCrumb redirect = _kryptonBreadCrumb.GetRedirector() as PaletteRedirectBreadCrumb; Size preferredSize = Size.Empty; for (var i = 1; i < Count; i++) { // Do not show the left border on the first crumb redirect.Left = i == 0; // Find size of the child Size childSize = this[i].GetPreferredSize(context); // Accumulate in width preferredSize.Width += childSize.Width; // Find maximum height preferredSize.Height = Math.Max(preferredSize.Height, childSize.Height); } // Add on the control level padding preferredSize.Width += _kryptonBreadCrumb.Padding.Horizontal; preferredSize.Height += _kryptonBreadCrumb.Padding.Vertical; return(preferredSize); }