-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Need a 'CellTemplateSelector' similar property in community's DataGrid control #2958
Comments
I want this too. |
@PaulaScholz Since the WindowsCommunityToolkit is open source. I spent some time to do some customizations for the DataGrid. Since I have no permission to push the changes to master, so I post the code here. Open the 'Microsoft.Toolkit.Uwp.UI.Controls.DataGrid.csproj' project and open the 'DataGridTemplateColumn.cs'. Add a 'cellTemplateSelector' property for it like the following:
Edit the 'GenerateElement' method like the following:
Then, you could compile the whole project and use the custom DataGrid control in your UWP project.
|
I believe that row recycling is throwing a wrench into that idea (it's a DataGrid feature that improves perf). A recycled row by default will not trigger a call to GenerateElement. So recycled rows would normally appear using incorrect cell templates. There is a trick to turn off a row's recycling. See private void UnloadRow(DataGridRow dataGridRow) in DataGridRows.cs:
You need to set the DataGridRow.Style property on all rows. This is to prevent them from being recycled, but it has perf implications. |
This issue has been marked as "Needs: Attention 👋" due to no activity for 7 days. Please triage and assign the issue so the fix can be established. |
This issue has been marked as "Needs: Attention 👋" due to no activity for 7 days. Please triage the issue so the fix can be established. |
We are not adding features to this DataGrid at this time. Please use @RBrid 's workaround above. If you would like to see this property in the newly proposed WinUI DataGrid, please add a comment in the WinUI discussion issue. |
I'm submitting a...
Feature request (UserVoice request: https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/38030980-need-a-celltemplateselector-relevant-things-in-c)
Current behavior
There's no sucn a property.
Expected behavior
I want such a 'CellTemplateSelector' property. Then, I can choose different dataTemplate for the CellTemplate by my own DataTemplateSelector.
Minimal reproduction of the problem with instructions
Environment
The text was updated successfully, but these errors were encountered: