DataGrid Header loses fluent styling when HorizontalContentAlignment property applied
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
### Description
DataGrid Header loses fluent styling when HorizontalContentAlignment property applied
Without any props on the datagrid header the header style is ok :
```xml
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
```
once
```xml
<Setter Property="HorizontalContentAlignment" Value="Center"/>
```
is enabled:
only the header becomes light theme
### Reproduction Steps
use this with a datagrid that has column headers and toggle the disabled prop:
```xml
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
```
maybe relevant .csproj:
```xml
WinExe
net9.0-windows
enable
enable
true
False
true
$(NoWarn);WPF0001
Properties\icon.ico
```
this is how I'm applying the theme:
```cs
public MainWindow() {
InitializeComponent();
Application.Current.ThemeMode = ThemeMode.System;
//...
}
```
### Expected behavior
The header should remain in dark mode, even if the text is centered. Works just fine for the datagrid cells, only the headers break.
### Actual behavior
Header goes to light theme, no errors that I've seen.
### Regression?
_No response_
### Known Workarounds
_No response_
### Impact
_No response_
### Configuration
```
dotnet --version
9.0.101
```
`systeminfo:`
```
systeminfo
Host Name:
OS Name: Microsoft Windows 11 Business
OS Version: 10.0.26100 N/A Build 26100
OS Manufacturer: Microsoft Corporation
OS Configuration: Member Workstation
OS Build Type: Multiprocessor Free
System Manufacturer: Dell Inc.
System Model: Precision 5770
System Type: x64-based PC
Processor(s): 1 Processor(s) Installed.
[01]: Intel64 Family 6 Model 154 Stepping 3 GenuineIntel ~2400 Mhz
BIOS Version: Dell Inc. 1.28.0, 9/26/2024
Windows Directory: C:\WINDOWS
System Directory: C:\WINDOWS\system32
Boot Device: \Device\HarddiskVolume1
System Locale: en-us;English (United States)
Input Locale: en-us;English (United States)
Time Zone: (UTC-08:00) Pacific Time (US & Canada)
Total Physical Memory: 32,453 MB
Available Physical Memory: 10,831 MB
Virtual Memory: Max Size: 44,229 MB
Virtual Memory: Available: 16,083 MB
Virtual Memory: In Use: 28,146 MB
Page File Location(s): C:\pagefile.sys
Logon Server: \\SERVER-ST-1
Hotfix(s): 4 Hotfix(s) Installed.
[01]: KB5054979
[02]: KB5058411
[03]: KB5058538
[04]: KB5058523
Virtualization-based security: Status: Running
Required Security Properties:
Available Security Properties:
Base Virtualization Support
Secure Boot
DMA Protection
UEFI Code Readonly
SMM Security Mitigations 1.0
Mode Based Execution Control
APIC Virtualization
Services Configured:
Hypervisor enforced Code Integrity
Services Running:
Hypervisor enforced Code Integrity
Hypervisor-Enforced Paging Translation
App Control for Business policy: Enforced
App Control for Business user mode policy: Off
Security Features Enabled:
Hyper-V Requirements: A hypervisor has been detected. Features required for Hyper-V will not be displayed.
```
### Other information
On light theme, it seems to be a slightly different control object (has highlighting on select, has arrows)
the sorting arrows work on light theme, but not dark. My guess is that it might be falling back to light theme because the dark ones are missing certain properties?
Contributor guide
Assessment
This issue has not been assessed yet.