Skip to main content
added 2 characters in body
Source Link
Romasz
  • 29.9k
  • 14
  • 85
  • 160

I've written and debuged a code below:

 private void myButton_Click(object sender, RoutedEventArgs e) { Color myColor = (Color)App.Current.Resources["PhoneAccentColor"]; App.Current.Resources.Remove("PhoneAccentColor"); bool contains = App.Current.Resources.Contains("PhoneAccentColor"); App.Current.Resources.Add("PhoneAccentColor", Colors.Brown); Color myCol = (Color)App.Current.Resources["PhoneAccentColor"]; // Below works LayoutRoot.Background = new SolidColorBrush((Color)App.Current.Resources["PhoneAccentColor"]); // Not working as you have to change Brush separately LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; // Now working App.Current.Resources.Add("PhoneAccentBrush", new SolidColorBrush(Colors.Cyan)); LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; return; } 

EDIT
It's working properly - but it's not the Resource you were looking for - it's just creating 'local' Resource which doesn't affect the 'real' PhoneAccentBrush - if you create new Page with Background from StaticResource it will have the default PhoneAccentBrush.
But what I managed to do:

 private void myButton_Click(object sender, RoutedEventArgs e) { Color myColor = (Color)App.Current.Resources["PhoneAccentColor"]; myColor.A = 255; myColor.B = 75; myColor.G = 150; myColor.R = 150; SolidColorBrush internalBrush = (SolidColorBrush)App.Current.Resources["PhoneAccentBrush"]; internalBrush.Color = myColor; return; } 

You cannot remove or override StaticResourcePhoneAccentBrush, but 'locally' (for your App) you can change it's properties. It works quite fine - after this Clisk event, when I create new Page, the PhoneAccentBrush is just as I've set it.

I've written and debuged a code below:

 private void myButton_Click(object sender, RoutedEventArgs e) { Color myColor = (Color)App.Current.Resources["PhoneAccentColor"]; App.Current.Resources.Remove("PhoneAccentColor"); bool contains = App.Current.Resources.Contains("PhoneAccentColor"); App.Current.Resources.Add("PhoneAccentColor", Colors.Brown); Color myCol = (Color)App.Current.Resources["PhoneAccentColor"]; // Below works LayoutRoot.Background = new SolidColorBrush((Color)App.Current.Resources["PhoneAccentColor"]); // Not working as you have to change Brush separately LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; // Now working App.Current.Resources.Add("PhoneAccentBrush", new SolidColorBrush(Colors.Cyan)); LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; return; } 

EDIT
It's working properly - but it's not the Resource you were looking for - it's just creating 'local' Resource which doesn't affect the 'real' PhoneAccentBrush - if you create new Page with Background from StaticResource it will have the default PhoneAccentBrush.
But what I managed to do:

 private void myButton_Click(object sender, RoutedEventArgs e) { Color myColor = (Color)App.Current.Resources["PhoneAccentColor"]; myColor.A = 255; myColor.B = 75; myColor.G = 150; myColor.R = 150; SolidColorBrush internalBrush = (SolidColorBrush)App.Current.Resources["PhoneAccentBrush"]; internalBrush.Color = myColor; return; } 

You cannot remove or override StaticResource, but 'locally' (for your App) you can change it's properties. It works quite fine - after this Clisk event, when I create new Page, the PhoneAccentBrush is just as I've set it.

I've written and debuged a code below:

 private void myButton_Click(object sender, RoutedEventArgs e) { Color myColor = (Color)App.Current.Resources["PhoneAccentColor"]; App.Current.Resources.Remove("PhoneAccentColor"); bool contains = App.Current.Resources.Contains("PhoneAccentColor"); App.Current.Resources.Add("PhoneAccentColor", Colors.Brown); Color myCol = (Color)App.Current.Resources["PhoneAccentColor"]; // Below works LayoutRoot.Background = new SolidColorBrush((Color)App.Current.Resources["PhoneAccentColor"]); // Not working as you have to change Brush separately LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; // Now working App.Current.Resources.Add("PhoneAccentBrush", new SolidColorBrush(Colors.Cyan)); LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; return; } 

EDIT
It's working properly - but it's not the Resource you were looking for - it's just creating 'local' Resource which doesn't affect the 'real' PhoneAccentBrush - if you create new Page with Background from StaticResource it will have the default PhoneAccentBrush.
But what I managed to do:

 private void myButton_Click(object sender, RoutedEventArgs e) { Color myColor = (Color)App.Current.Resources["PhoneAccentColor"]; myColor.A = 255; myColor.B = 75; myColor.G = 150; myColor.R = 150; SolidColorBrush internalBrush = (SolidColorBrush)App.Current.Resources["PhoneAccentBrush"]; internalBrush.Color = myColor; return; } 

You cannot remove or override PhoneAccentBrush, but 'locally' (for your App) you can change it's properties. It works quite fine - after this Clisk event, when I create new Page, the PhoneAccentBrush is just as I've set it.

added 732 characters in body
Source Link
Romasz
  • 29.9k
  • 14
  • 85
  • 160

I've written and debuged a code below:

 private void myButton_Click(object sender, RoutedEventArgs e) { Color myColor = (Color)App.Current.Resources["PhoneAccentColor"]; App.Current.Resources.Remove("PhoneAccentColor"); bool contains = App.Current.Resources.Contains("PhoneAccentColor"); App.Current.Resources.Add("PhoneAccentColor", Colors.Brown); Color myCol = (Color)App.Current.Resources["PhoneAccentColor"]; // Below works LayoutRoot.Background = new SolidColorBrush((Color)App.Current.Resources["PhoneAccentColor"]); // Not working as you have to change Brush separately LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; // Now working App.Current.Resources.Add("PhoneAccentBrush", new SolidColorBrush(Colors.Cyan)); LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; return; } 

It'sEDIT
It's working properly - adding new PhoneAccentColor, changes previous. Everything whatbut it's not the Resource you have said is truewere looking for - resource is not removedit's just creating 'local' Resource which doesn't affect the 'real' PhoneAccentBrush - but whenif you Add a resourcecreate new Page with Background from StaticResource it overrides previous onewill have the default PhoneAccentBrush. So that is why
But what I think code abovemanaged to do:

 private void myButton_Click(object sender, RoutedEventArgs e) { Color myColor = (Color)App.Current.Resources["PhoneAccentColor"]; myColor.A = 255; myColor.B = 75; myColor.G = 150; myColor.R = 150; SolidColorBrush internalBrush = (SolidColorBrush)App.Current.Resources["PhoneAccentBrush"]; internalBrush.Color = myColor; return; } 

You cannot remove or override StaticResource, but 'locally' (for your App) you can change it's properties. It works quite fine - after this Clisk event, when I create new Page, the PhoneAccentBrush is just as I've set it.

I've written and debuged a code below:

 private void myButton_Click(object sender, RoutedEventArgs e) { Color myColor = (Color)App.Current.Resources["PhoneAccentColor"]; App.Current.Resources.Remove("PhoneAccentColor"); bool contains = App.Current.Resources.Contains("PhoneAccentColor"); App.Current.Resources.Add("PhoneAccentColor", Colors.Brown); Color myCol = (Color)App.Current.Resources["PhoneAccentColor"]; // Below works LayoutRoot.Background = new SolidColorBrush((Color)App.Current.Resources["PhoneAccentColor"]); // Not working as you have to change Brush separately LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; // Now working App.Current.Resources.Add("PhoneAccentBrush", new SolidColorBrush(Colors.Cyan)); LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; return; } 

It's working properly - adding new PhoneAccentColor, changes previous. Everything what you have said is true - resource is not removed - but when you Add a resource it overrides previous one. So that is why I think code above works.

I've written and debuged a code below:

 private void myButton_Click(object sender, RoutedEventArgs e) { Color myColor = (Color)App.Current.Resources["PhoneAccentColor"]; App.Current.Resources.Remove("PhoneAccentColor"); bool contains = App.Current.Resources.Contains("PhoneAccentColor"); App.Current.Resources.Add("PhoneAccentColor", Colors.Brown); Color myCol = (Color)App.Current.Resources["PhoneAccentColor"]; // Below works LayoutRoot.Background = new SolidColorBrush((Color)App.Current.Resources["PhoneAccentColor"]); // Not working as you have to change Brush separately LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; // Now working App.Current.Resources.Add("PhoneAccentBrush", new SolidColorBrush(Colors.Cyan)); LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; return; } 

EDIT
It's working properly - but it's not the Resource you were looking for - it's just creating 'local' Resource which doesn't affect the 'real' PhoneAccentBrush - if you create new Page with Background from StaticResource it will have the default PhoneAccentBrush.
But what I managed to do:

 private void myButton_Click(object sender, RoutedEventArgs e) { Color myColor = (Color)App.Current.Resources["PhoneAccentColor"]; myColor.A = 255; myColor.B = 75; myColor.G = 150; myColor.R = 150; SolidColorBrush internalBrush = (SolidColorBrush)App.Current.Resources["PhoneAccentBrush"]; internalBrush.Color = myColor; return; } 

You cannot remove or override StaticResource, but 'locally' (for your App) you can change it's properties. It works quite fine - after this Clisk event, when I create new Page, the PhoneAccentBrush is just as I've set it.

deleted 68 characters in body
Source Link
Romasz
  • 29.9k
  • 14
  • 85
  • 160

I've written and debuged a code below:

 private void myButton_Click(object sender, RoutedEventArgs e) { Color myColor = (Color)App.Current.Resources["PhoneAccentColor"]; App.Current.Resources.Remove("PhoneAccentColor"); bool contains = App.Current.Resources.Contains("PhoneAccentColor"); App.Current.Resources.Add("PhoneAccentColor", Colors.Brown); Color myCol = (Color)App.Current.Resources["PhoneAccentColor"]; // Below works LayoutRoot.Background = new SolidColorBrush((Color)App.Current.Resources["PhoneAccentColor"]); // Not working as you have to change Brush separately LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; // Now working App.Current.Resources.Add("PhoneAccentBrush", new SolidColorBrush(Colors.Cyan)); LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; return; } 

It's working properly - adding new PhoneAccentColor, changes previous. Everything what you have said is true - resource is not removed - I think it cannot be, because some UI elements might be using them, but when you Add a resource it overrides previous one. So that is why I think code above works.

I've written and debuged a code below:

 private void myButton_Click(object sender, RoutedEventArgs e) { Color myColor = (Color)App.Current.Resources["PhoneAccentColor"]; App.Current.Resources.Remove("PhoneAccentColor"); bool contains = App.Current.Resources.Contains("PhoneAccentColor"); App.Current.Resources.Add("PhoneAccentColor", Colors.Brown); Color myCol = (Color)App.Current.Resources["PhoneAccentColor"]; // Below works LayoutRoot.Background = new SolidColorBrush((Color)App.Current.Resources["PhoneAccentColor"]); // Not working as you have to change Brush separately LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; // Now working App.Current.Resources.Add("PhoneAccentBrush", new SolidColorBrush(Colors.Cyan)); LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; return; } 

It's working properly - adding new PhoneAccentColor, changes previous. Everything what you have said is true - resource is not removed - I think it cannot be, because some UI elements might be using them, but when you Add a resource it overrides previous one. So that is why I think code above works.

I've written and debuged a code below:

 private void myButton_Click(object sender, RoutedEventArgs e) { Color myColor = (Color)App.Current.Resources["PhoneAccentColor"]; App.Current.Resources.Remove("PhoneAccentColor"); bool contains = App.Current.Resources.Contains("PhoneAccentColor"); App.Current.Resources.Add("PhoneAccentColor", Colors.Brown); Color myCol = (Color)App.Current.Resources["PhoneAccentColor"]; // Below works LayoutRoot.Background = new SolidColorBrush((Color)App.Current.Resources["PhoneAccentColor"]); // Not working as you have to change Brush separately LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; // Now working App.Current.Resources.Add("PhoneAccentBrush", new SolidColorBrush(Colors.Cyan)); LayoutRoot.Background = (Brush)App.Current.Resources["PhoneAccentBrush"]; return; } 

It's working properly - adding new PhoneAccentColor, changes previous. Everything what you have said is true - resource is not removed - but when you Add a resource it overrides previous one. So that is why I think code above works.

Source Link
Romasz
  • 29.9k
  • 14
  • 85
  • 160
Loading