Reusing DataGridColumn with different CellTemplate #5013
Unanswered
Shriniwaaaz
asked this question in
Questions & Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using a DataGrid with 3 columns, with different CellTemplates, where the 3rd column's details will be updated based on user input. So, I tried changing the CellTemplate of the 3rd column, but it didn't work. Then, I tried a different approach by replacing the 3rd column with a new column with different CellTemplate, but I get the below exception sometimes
Exception Trace: System.ArgumentOutOfRangeException: Index must be greater than or equal to 0 and less than 1.
Parameter name: index
at Microsoft.Toolkit.Uwp.UI.Controls.DataGridCellCollection.get_Item(Int32 index)
at Microsoft.Toolkit.Uwp.UI.Controls.Primitives.DataGridCellsPresenter.Recycle()
at Microsoft.Toolkit.Uwp.UI.Controls.DataGridRow.DetachFromDataGrid(Boolean recycle)
at Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.UnloadElements(Boolean recycle)
at Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.ClearRows(Boolean recycle)
at Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.RefreshRows(Boolean recycleRows, Boolean clearRows)
at Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.InitializeElements(Boolean recycleRows)
at Microsoft.Toolkit.Uwp.UI.Data.Utilities.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
at Microsoft.Toolkit.Uwp.UI.Data.Utilities.ListCollectionView.RefreshOverride()
at Microsoft.Toolkit.Uwp.UI.Data.Utilities.CollectionView.RefreshOrDefer()
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at Demo.App.ViewModel.DataGrid.Clear()
Is there any way to reuse the existing column by updating the CellTemplate? Or avoid getting the exception while replacing the column?
Thanks in Advance
Beta Was this translation helpful? Give feedback.
All reactions