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

DataGrid Header colours are not adapting to Dark Theme. (Are they not using ThemeResources?) #2373

Closed
mdtauk opened this issue Aug 8, 2018 · 9 comments
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior DataGrid 🔠 Issues on DataGrid control in progress 🚧

Comments

@mdtauk
Copy link

mdtauk commented Aug 8, 2018

I'm submitting a...

Bug report (I searched for similar issues and did not find one)

Current behavior

The Header row does not change colours to adapt to the Dark Theme. Either System Wide Dark Theme, or when toggling the RequestedTheme in the Sample App

data-grid-header-dark-in-light

data-grid-subheader-dark-in-light

Hover state also does not display correctly

data-grid-hover-header-dark-in-light

Expected behavior

The Header row should use an appropriate dark background with light foreground, whilst still offering differentiation with the rows below

data-grid-header-dark-in-light-expected

data-grid-subheader-dark-in-light-expected

Appropriate Hover states should be used as well.
data-grid-hover-header-dark-in-light-expected

Minimal reproduction of the problem with instructions

  • Open the Toolkit Sample App
  • Navigate to the DataGrid example
  • Set system or toggle example to Dark Theme

Environment

Nuget Package(s): 

Package Version(s): 

Windows 10 Build Number:
- [ ] Creators Update (15063)
- [ ] Fall Creators Update (16299)
- [X] April 2018 Update (17134)
- [ ] Insider Build (build number: )

App min and target version:
- [ ] Creators Update (15063)
- [ ] Fall Creators Update (16299)
- [X] April 2018 Update (17134)
- [ ] Insider Build (xxxxx)

Device form factor:
- [X] Desktop
- [ ] Mobile
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio 
- [ ] 2017 (version: )
- [ ] 2017 Preview (version: )

@kbrons kbrons added bug 🐛 An unexpected issue that highlights incorrect behavior DataGrid 🔠 Issues on DataGrid control labels Aug 8, 2018
@nmetulev
Copy link
Contributor

nmetulev commented Aug 8, 2018

This seems to be another issue when the theme is changed in runtime. Seems to work when the app is launched in dark theme.

@WilliamABradley, any thoughts on this?

@mdtauk
Copy link
Author

mdtauk commented Aug 8, 2018

ThemeResources update at runtime if the Theme changes, but StaticResources do not. So if you are using the ControlTemplate's ResourceDictionary, make sure you are calling on and using ThemeResources. See if that helps

@harinikmsft
Copy link
Contributor

@mdtauk is right, I do see a lot of resources specified as StaticResources which might be the source of the problem. @MSRegisB - can you take a look?

@lukeblevins
Copy link
Contributor

Although progress has been made in fixing this, I noticed that the DataGrid still fails to utilize the color defined with:

<controls:DataGrid.ColumnHeaderStyle>
      <Style TargetType="controlsprimitives:DataGridColumnHeader">
            <Setter Property="Background" Value="{ThemeResource ApplicationPageBackgroundThemeBrush}"/>
      </Style>
</controls:DataGrid.ColumnHeaderStyle>

@RexfelisLOC
Copy link

The following does not work either to change the background. The foreground changes but the background does not.

<Style x:Key="ColumnHeaderStyle" TargetType="primitives:DataGridColumnHeader">
    <Setter Property="Foreground" Value="Red"/>
    <Setter Property="Background" Value="Green"/>
</Style>

@KexyBiscuit
Copy link

Also, when changing theme from Dark to System(on my system it's Light), all text rows are totally white, instead of changing into black, making them invisible.

@Kyaa-dost Kyaa-dost added the no-recent-activity 📉 Open Issues that require attention label Oct 2, 2019
@RBrid
Copy link
Contributor

RBrid commented Oct 11, 2019

At this point, there is no bug when toggling the RequestedTheme in the Sample app from

  • Light to System
  • System to Light
  • Sytem to Dark
  • Light to Dark
  • Dark to Light
    As stated by KexyBiscuit, a bug occurs when changing from Dark to System. Rows need to be re-rendered to fix their colors.

Regarding ApplicationPageBackgroundThemeBrush, I think it's #FF1D1D1D in Dark theme and #FFF4F4F4 in Light theme.
The DataGridColumnHeader uses the DataGridColumnHeaderBackgroundColor resource.

Using this should work:

    <Color x:Key="ApplicationPageBackgroundThemeColor">#FFF4F4F4</Color> for Light
    <Color x:Key="ApplicationPageBackgroundThemeColor">#FF1D1D1D</Color> for Dark

    <StaticResource x:Key="DataGridColumnHeaderBackgroundColor" ResourceKey="ApplicationPageBackgroundThemeColor"/>

@lukeblevins
Copy link
Contributor

@RBrid I'm very happy to confirm that your method finally works! I'm now able to style the DataGrid headers to match my app's custom dark theme.
image

@harinikmsft
Copy link
Contributor

Customer unblocked.

@ghost ghost removed the no-recent-activity 📉 Open Issues that require attention label Oct 29, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Nov 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug 🐛 An unexpected issue that highlights incorrect behavior DataGrid 🔠 Issues on DataGrid control in progress 🚧
Projects
None yet
Development

No branches or pull requests

9 participants