Git thought this file was 0 sized but it's not; i'm confused

This commit is contained in:
Jake Norbut committed 2018-11-19 14:27:44 -06:00
1 parent 504323d5b7
commit f794ffdace
1 file changed
+50
@@ -0,0 +1,50 @@
using bts;
using mbts.spark.filters;
using mbts.ui.controls.adorners;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
namespace mbts.ui.controls {
public class UniformTabGrid : UniformGrid {
public UniformTabGrid () {
this.IsItemsHost = true;
this.Rows = 1;
}
protected override Size MeasureOverride(Size constraint) {
var child_tabs = this.Children.OfType<TabItem>();
var child_tabs_max_width = child_tabs.Sum(t => t.MaxWidth);
// I noticed when debugging that this can sometimes be infinty,
// especially when a TabItem has not been set with a MaxWidth.
if (!double.IsInfinity(child_tabs_max_width)) {
// if the window width is greater than the total tab width, then
// there is more than enough space for all the tabs. If this
// is set to the default of Stretch and the window has only 1
// tab or few tabs, the tab appears in the middle, which is not good.
// i.e. we want tabs to added left to right, so align left
//
// When the window is less than the total tab width, then align
// can be set to stretch b/c the UniformGrid will take care of
// sizing each tab accordingly.
this.HorizontalAlignment = (constraint.Width > child_tabs_max_width)
? HorizontalAlignment.Left
: HorizontalAlignment.Stretch;
// this bit here is necessary because when the window is expanded
// beyond the maxwidth of all the tabs, we switch to Left and the
// headers snap to some smaller than MaxWidth size, which is not
// the behavior we want
foreach (var child in child_tabs) {
child.Width = this.HorizontalAlignment == HorizontalAlignment.Left
? child.MaxWidth
: double.NaN;
}
}
return base.MeasureOverride(constraint);
}
}
}