c# - Removing the sort arrow from DataGrid programmatically in WPF -
in wpf application, have datagrid columns displays sortable data. user can sort , subsort whichever column wants.
i added button should clear sorting , return datagrid unsorted state using mvvm pattern (meaning button bound relaycommand in viewmodel, clears datagrid's datasource's sortdescriptions.)
this how code looks now:
viewmodellocator.myviewmodel.groupeditems.sortdescriptions.clear(); the datagrid's datasource groupeditems object (of type listcollectionview). when click button, see datagrid returns original, non-sorted state, however, sorting arrows in column headers remain if datagrid still sorted. how can programmatically remove these arrows?
to remove arrows in datagrid try:
foreach (var column in dt.columns) { column.sortdirection = null; } where dt datagrid.
Comments
Post a Comment