private void ResetColumnWidths() { if (!resetColumnWidthsPending) { resetColumnWidthsPending = true; Dispatcher.CurrentDispatcher.BeginInvoke( (Action)(() => { resetColumnWidthsPending = false; GridView view = listView.View as GridView; if (view != null) { listView.UpdateLayout(); // Prevent flickering on expanding columns (not collapsing though) foreach (GridViewColumn gridViewColumn in view.Columns) { bool?isFillColumn = RangeColumn.GetRangeIsFillColumn(gridViewColumn); if (!isFillColumn.HasValue || !isFillColumn.Value) { if (double.IsNaN(gridViewColumn.Width)) { gridViewColumn.Width = gridViewColumn.ActualWidth; gridViewColumn.Width = double.NaN; } } } } Dispatcher.CurrentDispatcher.BeginInvoke((Action)Refresh, DispatcherPriority.Render); }), DispatcherPriority.Render); } }
private bool IsFillColumn(GridViewColumn gridViewColumn) { if (gridViewColumn == null) { return(false); } GridView view = listView.View as GridView; if (view == null || view.Columns.Count == 0) { return(false); } bool?isFillColumn = RangeColumn.GetRangeIsFillColumn(gridViewColumn); return(isFillColumn.HasValue && isFillColumn.Value); }