Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code incomplete in section -To replace a generated column- #615

Open
GoTo-Romania opened this issue Feb 28, 2022 · 0 comments
Open

Code incomplete in section -To replace a generated column- #615

GoTo-Romania opened this issue Feb 28, 2022 · 0 comments

Comments

@GoTo-Romania
Copy link

https://docs.microsoft.com/en-us/windows/communitytoolkit/controls/datagrid_guidance/customize_autogenerated_columns#to-replace-a-generated-column

Code from section "To replace a generated column" also needs to set a .CellTemplate.

templateColumn.CellTemplate = new DataTemplate();

Without it I get an exception:

{"The type initializer for 'Missing template. Cannot initialize Microsoft.Toolkit.Uwp.UI.Controls.DataGridTemplateColumn.' threw an exception."}

" at Microsoft.Toolkit.Uwp.UI.Controls.DataGridTemplateColumn.GenerateElement(DataGridCell cell, Object dataItem)\r\n at Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.PopulateCellContent(Boolean isCellEdited, DataGridColumn dataGridColumn, DataGridRow dataGridRow, DataGridCell dataGridCell)\r\n at Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.AddNewCellPrivate(DataGridRow row, DataGridColumn column)\r\n at Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.CompleteCellsCollection(DataGridRow dataGridRow)\r\n at Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.GenerateRow(Int32 rowIndex, Int32 slot, Object dataContext)\r\n at Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.GenerateRow(Int32 rowIndex, Int32 slot)\r\n at Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.InsertDisplayedElement(Int32 slot, Boolean updateSlotInformation)\r\n at Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.GetExactSlotElementHeight(Int32 slot)\r\n at Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.UpdateDisplayedRows(Int32 newFirstDisplayedSlot, Double displayHeight)\r\n at Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.ComputeScrollBarsLayout()\r\n at Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.MeasureOverride(Size availableSize)"

With it the app starts ok but I get nothing in the cells because the CellTemplate is "empty"...


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant