using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; namespace Tango.FSE.LogViewer.UI.Controls { public class LogTabsGrid : Grid { public int Columns { get { return (int)GetValue(ColumnsProperty); } set { SetValue(ColumnsProperty, value); } } public static readonly DependencyProperty ColumnsProperty = DependencyProperty.Register("Columns", typeof(int), typeof(LogTabsGrid), new PropertyMetadata(0, (d, e) => (d as LogTabsGrid).OnColumnsChanged())); private void OnColumnsChanged() { ColumnDefinitions.Clear(); for (int i = 0; i < Columns; i++) { ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(1, GridUnitType.Star) }); } } protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved) { base.OnVisualChildrenChanged(visualAdded, visualRemoved); for (int i = 0; i < Children.Count; i++) { var element = Children[i] as FrameworkElement; if (element != null) { Grid.SetColumn(Children[i] as FrameworkElement, i); } } } } }