private void DataGrid_SizeChanged(object sender, SizeChangedEventArgs e) { if (ColumnsList != null && ColumnsList.Count > 0) { totalWidth = ColumnsList.Sum(x => x.Width); currentWidth = ColumnsList.Where(i => i.Visibility.Equals(true)).Sum(x => x.Width); } if (nextInlineColumn != null && nextInlineColumn.Width > 0) if ((currentWidth + nextInlineColumn.Width) <= DataGridExpander.ActualWidth) { ColumnsList[ColumnsList.LastIndexOf(nextInlineColumn)].Visibility = true; FindCurrentAndNextColumn(); } else if (currentWidth > ActualWidth) { ColumnsList[ColumnsList.LastIndexOf(currentVisibleColumn)].Visibility = false; FindCurrentAndNextColumn(); } currentWidth = DataGridExpander.ActualWidth; GenerateGridColumns(); }