In my setting page I have a listPicker
control, that have two values Dark
and Light
when I select Dark
from listpicker
I want to change background to Silver
foreground color to white
buttons background color to Black
, buttons foreground color to white
and accentcolor is black
of the application, and I am doing like below:
private void themelistPicker1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ListPickerItem lpi = (sender as ListPicker).SelectedItem as ListPickerItem;
themename = lpi.Content.ToString();
if (themename == "Dark")
{
SolidColorBrush brush = new SolidColorBrush();
brush.Color = Color.FromArgb(255, 192, 192, 192);
App.RootFrame.Background = brush;
((SolidColorBrush)Resources["PhoneAccentBrush"]).Color = Colors.Black;
((Color)Resources["PhoneForegroundColor"])= Colors.Black;
}
else
{
SolidColorBrush brush = new SolidColorBrush();
brush.Color = Color.FromArgb(255, 255, 255, 255);
App.RootFrame.Background = brush;
((SolidColorBrush)Resources["PhoneAccentBrush"]).Color = Colors.Blue;
((Color)Resources["PhoneForegroundColor"])= Colors.Black;
}
But it changes only the background and accentcolor color of the setting's page not all the application and also not change the foreground and buttons color of the application, why?
Kindly suggest me, waiting for reply.
Thanks
For doing this, define in App.xaml your custom SolidColorBrushes and then set them as Background/Foreground to all your controls. Then just change those Brushes and it will change all the controls.
Do not change colors to the system defined brushes, because all controls use them. That is why your code changes things you don't want to be changed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.