0

I need to change app's background color, that is behind this:

Frame rootFrame = Window.Current.Content as Frame;

That background color is either White or Black, depends on theme. For Light theme it is White, for Dark theme it is Black. I want to set custom color instead of default White and Black.

I have tried to change next colors:

SystemAltHighColor, SystemAltLowColor, SystemAltMediumColor, SystemAltMediumHighColor, SystemBaseHighColor, SystemBaseLowColor, SystemBaseMediumColor, SystemBaseMediumHighColor, SystemBaseMediumLowColor...

<ResourceDictionary.ThemeDictionaries>
    <ResourceDictionary x:Key="Light">
        <Color x:Key="SystemAltHighColor">#af0000</Color>
        <Color x:Key="SystemAltLowColor">#af0000</Color>
        <Color x:Key="SystemAltMediumColor">#af0000</Color>
        <Color x:Key="SystemAltMediumHighColor">#af0000</Color>
        <Color x:Key="SystemAltMediumLowColor">#af0000</Color>
        <Color x:Key="SystemBaseHighColor">#af0000</Color>
        <Color x:Key="SystemBaseLowColor">#af0000</Color>
        <Color x:Key="SystemBaseMediumColor">#af0000</Color>
        <Color x:Key="SystemBaseMediumHighColor">#af0000</Color>
        <Color x:Key="SystemBaseMediumLowColor">#af0000</Color>
    </ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

But no luck.

Does anyone know what color or brush is it?

user3239349
  • 877
  • 1
  • 12
  • 33
  • This is WPF, I need for UWP. – user3239349 Oct 09 '17 at 11:48
  • Can you show us the code by which you are overriding the colors that you mentioned ? I think you are not overriding the theme resources correctly.. – Pratyay Oct 09 '17 at 11:48
  • 1
    Possible duplicate of [Changing Theme in Windows 10 UWP App Programmatically](https://stackoverflow.com/questions/34554871/changing-theme-in-windows-10-uwp-app-programmatically) – Ferus7 Oct 09 '17 at 11:49
  • No, I just need that one property, that one color that holds the information about that background color, it does nothing to do with changing themes. I have updated my question with code that overriding the colors. – user3239349 Oct 09 '17 at 11:51
  • I want to put my custom color to background. – user3239349 Oct 09 '17 at 11:52
  • Check: [this](https://stackoverflow.com/a/33876758/7923571) so add `` and delete the rest of them – Ferus7 Oct 09 '17 at 11:55
  • I have tried that, but not luck. That answer is about page's default background. I need to set custom background to global App, it is behind Window.Current.Content, in App.cs – user3239349 Oct 09 '17 at 11:58

2 Answers2

1

You can override the background color for the application from code behind like this :

var brush = (SolidColorBrush)this.Resources["ApplicationPageBackgroundThemeBrush"];
brush.Color = Color.FromArgb(255, 242, 101, 34);

This will override the color for the ApplicationPageBackgroundThemeBrushand will produce the following output.

enter image description here

Hope this helps..

Pratyay
  • 1,291
  • 14
  • 23
-1
<Page
x:Class="DataUsageMeter.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:DataUsageMeter"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"   
Width="Auto" 
Height="Auto"
Background="#2d2d2d">. . . </Page>

Change #2d2d2d with your preferred color

CSA
  • 29
  • 8