// ---------------- protected override Size MeasureContentOverride(Size availableSize) { ScrollBar.Measure(availableSize); ScrollBarHeight = ScrollBar.DesiredSize.Height; Size buttonSize = new Size(ScrollBarHeight, ScrollBarHeight); ZoomInButton.Measure(buttonSize); ZoomOutButton.Measure(buttonSize); var availableLegendHeight = Math.Max(0, availableSize.Height - ScrollBarHeight); Legend.Measure(new Size(availableSize.Width, availableLegendHeight)); //use scrollbar and Legend to deal with infinite space. return(new Size(Legend.DesiredSize.Width, ScrollBarHeight + Legend.DesiredSize.Height)); }
// ---------------- protected override Size MeasureContentOverride(Size availableSize) { CalculateScrollBarValues(); ScrollBar.Measure(availableSize); ScrollBarWidth = ScrollBar.DesiredSize.Width; Size buttonSize = new Size(ScrollBarWidth, ScrollBarWidth); ZoomInButton.Measure(buttonSize); ZoomOutButton.Measure(buttonSize); double availableLegendWidth = Math.Max(0, availableSize.Width - ScrollBarWidth); Legend.Measure(new Size(availableLegendWidth, availableSize.Height)); //use scrollbarDockPanel or Legend to deal with infinite space. return(new Size(Legend.DesiredSize.Width + ScrollBarWidth, Legend.DesiredSize.Height)); }