Is there any way to have to tabcontrol take the size of the largest tab item (well, actually, the tabitem\'s content)?
Since the tabcontrol has no specific size assi
Actually, it was easier to solve that I thought.
Since I had a controltemplate for the TabControl anyway, I set the height of the ContentPresenter presenting the selected tab content. I do this using a converter that binds to the items of the TabControl, measures them if necessary (using Measure) and checks DesiredSize for the size I need.
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 height = content.DesiredSize.Height;
if (max < height)
max = height;
}
return max;
}
That works just fine, with some caveats:
FrameworkElement