You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fluent2 datagrid cell style based on DefaultDataGridCellStyle #10351
I want to adapt the .net 9 fluent theme's DefaultDataGridCellStyle so the grid cells do not look that cramped. Thus, I added a border and centered the cell's content:
Using that code, I override the default ControlTemplate completely and loose existing functionality. Instead I want to add those changes to the existing template. How can I achieve this? Or is there an overall better way?
I need the dark and the light theme to work as they are supposed to.
The issue is not about a specific feature lost though; it's about preserving all inherent framework functionalities. I aim to maintain the default behaviors while just adding a padding to each cell content and center it. Ideally it's future proof, i.e. I don't want to copy the whole ControlTemplate code of the default fluent style, as this might be changed in the future.
There is DataGrid.CellStyle and DataGridBoundColumn.ElementStyle. Setting Margin using cell style seems to be having an effect, although the margin is outside of cell borders, so depending on your design, it might not be helpful. Setting Padding doesn't do anything and that should be fixed in all the themes.
Activity
himgoyalmicro commentedon Jan 29, 2025
@johanneskopf Can you please share what all functionalities are you losing by using this style and can you please also share a sample repro?
johanneskopf commentedon Jan 29, 2025
@himgoyalmicro find the sample repro here: https://github.com/johanneskopf/sample-DefaultDataGridCellStyle-override
This shows that after applying a custom ControlTemplate to the DataGridCells of my DataGrid, row highlighting no longer functions as intended.
The issue is not about a specific feature lost though; it's about preserving all inherent framework functionalities. I aim to maintain the default behaviors while just adding a padding to each cell content and center it. Ideally it's future proof, i.e. I don't want to copy the whole ControlTemplate code of the default fluent style, as this might be changed in the future.
miloush commentedon Jan 29, 2025
There is
DataGrid.CellStyleandDataGridBoundColumn.ElementStyle. SettingMarginusing cell style seems to be having an effect, although the margin is outside of cell borders, so depending on your design, it might not be helpful. SettingPaddingdoesn't do anything and that should be fixed in all the themes.