Repository navigation
Description
Description
The Fluen2 DataGrid style has A LOT of issues. Styling is one of them #9562. However, another major one is the column headers don't support sorting indicators.
This is a deeper issue as the Fluent theme doesn't have an implementation of DataGridHeaderBorder which all other themes like Aero2 include.
It looks like this control hard-codes in C# background colors. This is especially problematic.
Reproduction Steps
Try to sort a vanilla Fluent2 styled DataGrid. If you look at the styles you can also see it is missing the mechanism to even support sort indicators in the XAML.
wpf/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Styles/DataGrid.xaml
Lines 369 to 379 in 43f4bc5
| <Border | |
| x:Name="columnHeaderBorder" | |
| Padding="3,0,3,0" | |
| Background="{TemplateBinding Background}" | |
| BorderBrush="{TemplateBinding BorderBrush}" | |
| BorderThickness="0,0,1,1"> | |
| <ContentPresenter | |
| HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |
| VerticalAlignment="{TemplateBinding VerticalContentAlignment}" | |
| SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /> | |
| </Border> |
Expected behavior
Sorting indicator arrows are needed for all columns.
Actual behavior
No sorting arrows
Regression?
No response
Known Workarounds
No response
Impact
No response
Configuration
No response
Other information
No response
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fields☑ Done
Activity
robert-abeo commentedon Feb 4, 2025
Also this seems to be a bug. It should be using the
BrushNOTColorwpf/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Styles/DataGrid.xaml
Line 362 in 43f4bc5
robert-abeo commentedon Feb 4, 2025
@dipeshmsft Please take a look at this one. It is a special case with
DataGridHeaderBorderhard-coding brushes in C# directly. This breaks the design of the Fluent theme and will require some special considerations and thought.wpf/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Aero2/Microsoft/Windows/Themes/DataGridHeaderBorder.cs
Lines 112 to 141 in 43f4bc5
dipeshmsft commentedon Feb 5, 2025
@robert-abeo, we will have to take a deep dive into DataGrid, I will take a look at this.
dipeshmsft commentedon Feb 12, 2025
@robert-abeo this won't be an issue. The other themes used this DataGridHeaderBorder control in DataGridColumnHeader style whereas we won't use that control in Fluent style, so I think we can find some way to deal with this.
robert-abeo commentedon Feb 12, 2025
@dipeshmsft Again, the
DataGridheader seems to require this DataGridHeaderBorder to properly manage sorting indicators. If I look at the source code there is a lot of other functionality there as well.You may be able to work-around the sorting indicators by setting a DataTrigger in the style based on SortDirection for the column; however, that isn't done right now. Sorting indicators are completely non-functional.
I suspect a lot of the other functionality is there fore a reason as well.
dipeshmsft commentedon Feb 13, 2025
@robert-abeo I am working on this currently. Will update you once I have some more information on this.
dipeshmsft commentedon Feb 19, 2025
@robert-abeo you can see a preview of the datagrid changes here in this PR : Restyled DataGrid and component controls
This is still to be reviewed internally and once done I will raise it here for review from community.
robert-abeo commentedon Feb 19, 2025
@dipeshmsft Thanks, will look at it in more detail later. Some initial thoughts just looking at the images:
For reference here is what a custom "Fluent2" styled DataGrid looks like on my end.
dipeshmsft commentedon Feb 19, 2025
Thanks for these points, I will try to incorporate them during the internal discussion.
dipeshmsft commentedon Apr 9, 2025
@robert-abeo
Regarding this, what are the things that you are talking about ? If you are talking about margin and padding, fixing that would cause inconsistencies in the editing mode, as the textbox loaded in data grid, is code generated and it will require a lot of workarounds to fix the fluent style loading for datagrid elements.
Let me try out other colors here.
I have added color change for the whole row when the selection is made, so there is visual feedback even if header's visibility is hidden. I can modify the colors of the row, but making it like Fluent may need serious changes in data grid.
robert-abeo commentedon Apr 25, 2025
If the editable controls are fully generated by code then nevermind -- it is what it is. I would prefer a styling a little closer to Fluent overall but we will manage this on our end with custom styles.
DataGrid fundamentally was not a well designed control in some areas. It is hard-coded things that go against WPF lookless control principles.
I think changing the whole row background on selection is the best option. That is what is done on our side. We can't use Fluent's selection pill concept here for above reasons.
dipeshmsft commentedon Jun 5, 2025
Closing this issue as the corresponding PR has been merged. Moving other DataGrid related comments to the main issue #10445.