private static void UpdateItemsSource(DataGrid dataGrid) { IEnumerable view = null; var rowsSource = (IEnumerable<IEnumerable>)dataGrid.GetRowsSource(); if (rowsSource != null) { view = new Lists2DView(rowsSource); } var colsSource = (IEnumerable<IEnumerable>)dataGrid.GetColumnsSource(); if (colsSource != null) { view = new Lists2DTransposedView(colsSource); } var transposedSource = dataGrid.GetTransposedSource(); if (transposedSource != null) { view = new TransposedItemsSource(transposedSource); } dataGrid.Bind(ItemsControl.ItemsSourceProperty) .OneWayTo(view); dataGrid.RaiseEvent(new RoutedEventArgs(Events.ColumnsChanged)); }