/// <summary>
        /// Updates a rectangle that fills the header in which a label can be placed.
        /// </summary>
        /// <param name="node">The group node.</param>
        /// <param name="header">The visual to update.</param>
        /// <returns>The updated header rectangle.</returns>
        private static Rectangle RenderHeader(INode node, Rectangle header)
        {
            // the lower corner is the anchor of the label.
            var anchorX = node.Layout.X;
            var anchorY = node.Layout.GetMaxY();

            // Calculate the box of the label. It uses the whole width of the node.
            var width        = node.Layout.Width;
            var headerHeight = HeaderHeight;
            var firstLabel   = node.Labels.FirstOrDefault();

            if (firstLabel != null)
            {
                headerHeight = Math.Max(headerHeight, firstLabel.GetLayout().Height);
            }

            var oldCache = header.GetRenderDataCache <HeaderRenderData>();
            var newCache = new HeaderRenderData {
                AnchorX = anchorX, AnchorY = anchorY, Width = width, HeaderHeight = headerHeight
            };

            if (!newCache.Equals(oldCache))
            {
                header.SetRenderDataCache(newCache);
                header.SetCanvasArrangeRect(new Rect(anchorX, anchorY - headerHeight, width, headerHeight));
            }
            return(header);
        }
 private bool Equals(HeaderRenderData other)
 {
     return(other.AnchorX == AnchorX && other.AnchorY == AnchorY && other.Width == Width && other.HeaderHeight == HeaderHeight);
 }