I'm writing an app for the universal windows platform using the dark theme and I've noticed that although I've correctly set the requested theme to dark when I display a modal dialog using the ContentDialog
class the overlay lightens the overall page rather than darkening it.
Before dialog displayed:
With dialog displayed:
Since there isn't a property on ContentDialog
to control the overlay how do I override the colour being used?
Try the below code.
Now, Call the above method on your code behind like this----
Here, "this" represent the Content Dialog reference or you can pass the object reference of the ContectDialog.
Hope, this will help you to change the color of the Overlay. Happy Coding .. :)
I used the code for the accepted answer, but changing the color of this brush worked for me... "SystemControlPageBackgroundMediumAltMediumBrush" Maybe because i am using Anniversary Edition as I read here
Also make sure your resource dictionary key matches the theme you are using. I was using the "Light" theme, so I changed the Resource dictionary x:key to this...
I used the below code in App.xaml. It works for me properly.
<Application.Resources> <SolidColorBrush x:Key="SystemControlPageBackgroundMediumAltMediumBrush" Color="#00000000" /> </Application.Resources>
After some experimentation I've found that the brush being used to control the colour of the overlay that a
ContentDialog
is displayed above isSystemControlPageBackgroundBaseMediumBrush
rather than the more likely lookingContentDialogDimmingThemeBrush
.By inspecting the default theme definitions it emerges that both light and dark themes set this brush to the colour resource
SystemBaseMediumColor
which on the light theme is#99000000
and on the dark theme is#99FFFFFF
. This results in the overlay darkening the light theme and lightening the dark theme.Since
SystemBaseMediumColor
is references by other brush definitions such as those used for inactive pivot titles it's necessary to overrideSystemControlPageBackgroundBaseMediumBrush
rather than the colour it references solely for the dark theme.To do this we need to redefine the brush in a resource theme dictionary in
App.xaml
or in a resource XAML file merged intoApp.xaml
along the lines of: