protected override Size ArrangeContentOverride(Rect arrangeRect)
        {
            CalculateScrollBarValues();

            double legendHeight = Math.Max(0, arrangeRect.Size.Height - ScrollBarHeight);
            double legendY      = 0;

            if (IsSizingHeightToExpandableContent())
            {
                //use all the width, but only the height needed
                legendHeight = Math.Min(legendHeight, Legend.DesiredSize.Height);
            }
            double scrollbarY = legendHeight;

            if (!double.IsNaN(Height) || VerticalAlignment == VerticalAlignment.Stretch)
            {
                //VerticalContentAlignment matters only if space available is different from the needed space, which is only possible if
                //LegendX is stretched or its height is defined
                switch (VerticalContentAlignment)
                {
                case VerticalAlignment.Top:
                case VerticalAlignment.Stretch:
                    break;

                case VerticalAlignment.Center:
                    legendY    = (arrangeRect.Size.Height - legendHeight - ScrollBarHeight) / 2;
                    scrollbarY = (arrangeRect.Size.Height - legendHeight + ScrollBarHeight) / 2;
                    break;

                case VerticalAlignment.Bottom:
                    legendY    = arrangeRect.Size.Height - legendHeight - ScrollBarHeight;
                    scrollbarY = arrangeRect.Size.Height - ScrollBarHeight;
                    break;

                default:
                    throw new NotSupportedException();
                }
            }

            Legend.ArrangeBorderPadding(arrangeRect, 0, legendY, arrangeRect.Size.Width, legendHeight);
            ZoomOutButton.ArrangeBorderPadding(arrangeRect, 0, scrollbarY, ScrollBarHeight, ScrollBarHeight);
            ScrollBar.ArrangeBorderPadding(arrangeRect, ScrollBarHeight, scrollbarY, Math.Max(0, arrangeRect.Size.Width - 2 * ScrollBarHeight), ScrollBarHeight);
            ZoomInButton.ArrangeBorderPadding(arrangeRect, arrangeRect.Width - ScrollBarHeight, scrollbarY, ScrollBarHeight, ScrollBarHeight);


            //if (IsSizingHeightToExpandableContent()) {
            //  return new Size(arrangeRect.Size.Width, legendHeight + scrollHeight);
            //} else {
            return(arrangeRect.Size);
            //}
        }
Exemple #2
0
        protected override Size ArrangeContentOverride(Rect arrangeRect)
        {
            CalculateScrollBarValues();

            double legendWidth = arrangeRect.Size.Width - ScrollBarWidth;
            double legendX     = 0;

            if (IsSizingWidthToExpandableContent())
            {
                //use all the height, but only the width needed
                legendWidth = Math.Min(legendWidth, Legend.DesiredSize.Width);
            }
            double scrollbarX = legendWidth;

            if (!double.IsNaN(Width) || HorizontalAlignment == HorizontalAlignment.Stretch)
            {
                //HorizontalContentAlignment matters only if space available is different from the needed space, which is only possible if
                //LegendY is stretched or its width is defined
                switch (HorizontalContentAlignment)
                {
                case HorizontalAlignment.Left:
                case HorizontalAlignment.Stretch:
                    break;

                case HorizontalAlignment.Center:
                    legendX    = (arrangeRect.Size.Width - legendWidth - ScrollBarWidth) / 2;
                    scrollbarX = (arrangeRect.Size.Width + legendWidth - ScrollBarWidth) / 2;
                    break;

                case HorizontalAlignment.Right:
                    legendX    = arrangeRect.Size.Width - legendWidth - ScrollBarWidth;
                    scrollbarX = arrangeRect.Size.Width - ScrollBarWidth;
                    break;

                default:
                    throw new NotSupportedException();
                }
            }

            Legend.ArrangeBorderPadding(arrangeRect, legendX, 0, legendWidth, arrangeRect.Size.Height);
            ZoomInButton.ArrangeBorderPadding(arrangeRect, scrollbarX, 0, ScrollBarWidth, ScrollBarWidth);
            ScrollBar.ArrangeBorderPadding(arrangeRect, scrollbarX, ScrollBarWidth, ScrollBarWidth, Math.Max(0, arrangeRect.Size.Height - 2 * ScrollBarWidth));
            ZoomOutButton.ArrangeBorderPadding(arrangeRect, scrollbarX, arrangeRect.Height - ScrollBarWidth, ScrollBarWidth, ScrollBarWidth);


            //if (IsSizingHeightToExpandableContent()) {
            //  return new Size(arrangeRect.Size.Width, legendHeight + scrollHeight);
            //} else {
            return(arrangeRect.Size);
            //}
        }