In a XAML winrt app, can I apply dark theme to only one element?

I am using a media player with a framework and I got it on a black background, but the app uses a light theme. I would like to apply dark theme to just one element.

Is it possible?

+3


source to share


3 answers


This is not currently possible in WinRT. In the case of a black background in a light theme, you must define your own styles and combine them in specific container resources (in your case, it is Gird).



+2


source


Yes, you can place an item in a grid and set the "Grid" background to black. This will effectively always make the background of the element black, even if the "light" theme is applied.



0


source


I have not tested if this will work, but you can try to include the dark resource dictionary to the one that should be somewhere (or near) "c: \ Program Files (x86) \ Windows Kits \ 8.0 \ Include \ winrt \ xaml \ design "in your project and set it as a unified dictionary for the Grid. Perhaps this will replace the light theme dictionary you have installed for the rest of the app.

An alternative is to change the templates for all controls used in the media player to match their dark theme versions. Blend can be really useful there as you can open two instances of Blend and easily compare the colors used in the base dark version of the control theme and your own dark versions of the themes.

0


source







All Articles