public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var items = value as ItemCollection;
if (items == null) {
return null;
}
double max = 0;
foreach (TabItem item in items) {
var content = item.Content as FrameworkElement;
if (content == null) {
continue;
}
if (!content.IsMeasureValid) {
content.Measure(new Size(int.MaxValue, int.MaxValue));
}
var length = _checkHeight ? content.DesiredSize.Height : content.DesiredSize.Width;
if (max < length) {
max = length;
}
}
return max;
}