I have a few styles in my App.xaml file:
Why are you modifying the Style instead of setting the Background-Property of your targeted StackPanel directly? Since a 'Local value' has a higher precedence than 'Style setters' the value that you write into Background from code behind would be used
Means:
(1) Give a name to your stackpanel x:Name="spBla"
(2) Assign the Brush to the Background of spBla ( something like spBla.Background=Application.Current.Resources["styleRed"] as SolidColorBrush; )
You can learn more about value precedence here:
http://msdn.microsoft.com/en-us/library/ms743230(v=vs.110).aspx