private void LayoutCharts()
{
// layout charts to fill the space available.
double height = ChartStack.ActualHeight;
double count = ChartStack.ChartCount;
height -= (count * (defaultChartMargin.Top + defaultChartMargin.Bottom)); // remove margins
double chartHeight = Math.Min(MaxChartHeight, height / count);
bool found = false;
foreach (FrameworkElement c in ChartStack.Charts)
{
found = true;
c.Height = chartHeight;
}
if (!found)
{
ChartStack.Visibility = Visibility.Collapsed;
}
}