Zia Ur Rahman
Zia Ur Rahman

Reputation: 1880

How to change background overlay of ContentDialog uwp

I am developing UWP Win10 App using VS2015. I am using ContenDialog to show a Modal Window / Popup. I need to change the Background Overlay color of ContentDialog. How to do this. There is no option/property even in the inner Style too.

I need to change the Overlay White Dim color to some other color like Blackish overlay/dim color etc...

See the pic.

enter image description here

Upvotes: 0

Views: 2484

Answers (2)

Chris Schaller
Chris Schaller

Reputation: 16554

The key resource to set is SystemControlPageBackgroundMediumAltMediumBrush

I use the following theme definition to target all ContentDialogs in my apps:

<!--  override the Dialog Background  -->
<ResourceDictionary.ThemeDictionaries>
    <ResourceDictionary x:Key="Default">
        <SolidColorBrush x:Key="ContentDialogDimmingThemeBrush" Color="#99FFFFFF" />
        <SolidColorBrush x:Key="SystemControlPageBackgroundMediumAltMediumBrush" Color="#99000000" />
        <StaticResource x:Key="ContentDialogLightDismissOverlayBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" />
    </ResourceDictionary>
    <ResourceDictionary x:Key="Dark">
        <SolidColorBrush x:Key="ContentDialogDimmingThemeBrush" Color="{ThemeResource SystemColorHighlightColor}" />
        <SolidColorBrush x:Key="SystemControlPageBackgroundMediumAltMediumBrush" Color="#99000000" />
        <StaticResource x:Key="ContentDialogLightDismissOverlayBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" />
    </ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

Upvotes: 5

thang2410199
thang2410199

Reputation: 1942

I think you need custom use control to have more control over the background. The default ContenDialog provide very bare bone setup and has limitations to the number of buttons / contents.

Upvotes: 1

Related Questions