Home Forums WPF controls Xceed DataGrid for WPF Manipulating Columns with AutoCreateColumns=true

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #23470 |

    I would like to do something like the following:

    DataGridCollectionViewSource view;
    DataGridControl searchResults;

    searchResults.AutoCreateColumns = true;

    view = Resources[“searchResultsView”] as DataGridCollectionViewSource;
    view.Source = someIEnumerable;
    searchResults.ItemsSource = view.View;

    view.ItemProperties.Clear();
    foreach (PropertyInfo p in displayMe)
    {
    view.ItemProperties.Add(new DataGridItemProperty(…));
    }

    But, it seems that ItemProperties gets cleared again and the grid shows all properties of my data object.

    Is there some event I can hook that fires AFTER the columns are AutoCreated? If not, could you please add one?

    Imported from legacy forums. Posted by Joao (had 2388 views)

    Xceed Support
    Member
    Post count: 5658

    Try setting the ItemsProperties on the DataGridCollectionView before setting the DataGridCollectionView on the DataGridControl. Columns are created/updated when ItemsSource is originally assigned.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 216 views)

    User (Old forums)
    Member
    Post count: 23064

    That was it, thanks!

    Imported from legacy forums. Posted by Joao (had 3455 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.