How to save status bar background color in local settings(Windows Phone 8.1)

I have given the user the freedom to change background colour and save it in local settings. But I am confused on how to save the status bar colour settings because I want to give the user the freedom to choose from 4-5 colours where background of status bar
can be changed.
public static void SaveStatusBarColor()
// get status bar color
var statusBar = StatusBar.GetForCurrentView();
var color = statusBar.BackgroundColor;
// convert color to hex string
var hexCode = color.HasValue ? color.Value.ToString() : "";
// store color in local settings
ApplicationData.Current.LocalSettings.Values["StatusBarColor"] = hexCode;
public static void LoadStatusBarColor()
// get color hex string from local settings
var hexCode = ApplicationData.Current.LocalSettings.Values["StatusBarColor"] as string;
if (string.IsNullOrEmpty(hexCode))
return;
// convert hexcode to color
var color = new Color();
color.A = byte.Parse(hexCode.Substring(1, 2), NumberStyles.AllowHexSpecifier);
color.R = byte.Parse(hexCode.Substring(3, 2), NumberStyles.AllowHexSpecifier);
color.G = byte.Parse(hexCode.Substring(5, 2), NumberStyles.AllowHexSpecifier);
color.B = byte.Parse(hexCode.Substring(7, 2), NumberStyles.AllowHexSpecifier);
// set the status bar color
var statusBar = StatusBar.GetForCurrentView(); // Exception Line
statusBar.BackgroundColor = color;
}This is what was suggested to me. Initially the app runs and saves the settings.But when the app is closed and restarted again it crashes.

Hi shriyansh,
Where did you call the method SaveStatusBarColor() and LoadStatusBarColor()?
I have called your SaveStatusBarColor() in the OnNavigatedFrom method and called the LoadStatusBarColor() in the OnNavigatedTo method, it worked very well in my side.
So I can not reproduce your issue.
Here are my code and result, please try to check it:
public class test
public Color colors { get; set; }
public sealed partial class MainPage : Page
List<test> testdemo = new List<test>();
public MainPage()
this.InitializeComponent();
testdemo.Add(new test() { colors = Colors.Red });
testdemo.Add(new test() { colors = Colors.Green});
testdemo.Add(new test() { colors = Colors.Gray});
testdemo.Add(new test() { colors = Colors.Blue });
this.NavigationCacheMode = NavigationCacheMode.Required;
public static void SaveStatusBarColor()
// get status bar color
var statusBar = StatusBar.GetForCurrentView();
var color = statusBar.BackgroundColor;
// convert color to hex string
var hexCode = color.HasValue ? color.Value.ToString() : "";
// store color in local settings
ApplicationData.Current.LocalSettings.Values["StatusBarColor"] = hexCode;
public static void LoadStatusBarColor()
//get color hex string from local settings
var hexCode = ApplicationData.Current.LocalSettings.Values["StatusBarColor"] as string;
if (string.IsNullOrEmpty(hexCode))
return;
// convert hexcode to color
var color = new Color();
color.A = byte.Parse(hexCode.Substring(1, 2), NumberStyles.AllowHexSpecifier);
color.R = byte.Parse(hexCode.Substring(3, 2), NumberStyles.AllowHexSpecifier);
color.G = byte.Parse(hexCode.Substring(5, 2), NumberStyles.AllowHexSpecifier);
color.B = byte.Parse(hexCode.Substring(7, 2), NumberStyles.AllowHexSpecifier);
var statusBar = StatusBar.GetForCurrentView();
statusBar.BackgroundColor = color;
statusBar.BackgroundOpacity = 1;
protected override void OnNavigatedTo(NavigationEventArgs e)
LoadStatusBarColor();
protected override void OnNavigatedFrom(NavigationEventArgs e)
SaveStatusBarColor();
private void ChangeColorButton_Click(object sender, RoutedEventArgs e)
var statusBar = StatusBar.GetForCurrentView();
statusBar.BackgroundColor = testdemo[Convert.ToInt32(Mytextbox.Text)].colors;
statusBar.BackgroundOpacity = 1;
The result:
Best Regards,
Amy Peng
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • How do I ge tthe background color of a browser window.

    How do I get the default backgound color of a browser. I made my Applet with white as the background color. My supervisor's IE settings makes his IE background color tan. Is there any way I can read that "tan" from somewhere and use that as my Applet background color?

    I am trying that, but it doesn't look like it is taking the parameters...
    I display the text on the html page as well, it seems to display ok, but the applet is not taking the parameter.
    <applet
      codebase = "."
      code     = "graphapplet.GraphApplet.class"
      name     = "TestApplet"
      width    = "400"
      height   = "300"
      hspace   = "0"
      vspace   = "0"
      align    = "middle"
    >
    <SCRIPT LANGUAGE="JavaScript">
    document.write("<param name = \"bgColor\" value = \"" + document.bgColor + "\">");
    </SCRIPT>
    <param name = "Filename" value = "data.txt">
    </applet>
    <SCRIPT LANGUAGE="JavaScript">
    document.write("param name = \"bgcolor\" value = \"" + document.bgColor + "\"");
    </SCRIPT>

  • How can i change the background color in the mobile windows adobe reader app? i want to change it from black to white but don't know how.

    really want to change the background color of my documents in the mobile app. ive tried to search the answer online, in blogs and other various 'life hacks' blogs or articles, but so far everyone is talking about the desktop version. i really want to figure this out. is there even an option for the mobile version for windows? the only editing icons when a document is open are: export, home, make public, search in document, highlight/strikethrough/underline/comment and continuous/single view. if there isnt an option to edit background color, can i suggest that the makers of the windows mobile version make one, and make it fast please! any help would be appreciated. -CHANGE BACKGROUND COLOR

    hi, thanks for helping me ...
    i have used the above url and made changes to my OAF page, but i didn't get the desired output and its also giving as the above code output .
    i kept OraBgGrayVeryDark in Css style in property inspector for every region including PageLayout and i also did some changes in cabo/styles/*.css classes.
    eventhough it is picking the color upto footer level only and it is not applying for advanced table also.
    can anyone please give your views in this..

  • How can I change the background color in the inbox?

    The background color in my inbox (well, all mailboxes) is white. A yellow background would make the existing black text a lot easier to read. How can I change the background color in the inbox?

    Themes work in Thunderbird - duggabe was not refering to Firefox.
    Another useful addon is theme and font changer:
    * https://addons.mozilla.org/fr/thunderbird/addon/theme-font-size-changer/
    However, Thunderbird allows you to modify all sorts of things.
    Make hidden files and folders visible:
    * http://kb.mozillazine.org/Show_hidden_files_and_folders
    Help > Troubleshooting Information
    Click on 'show Folder' button
    a window opens shwoing profile folder name
    Close Thunderbird now - this is important
    In the profile name folder, Create a new folder called '''chrome''' - note the spelling
    It should be in the same place as the 'Mail' folder.
    see first image below.
    Open Notepad
    Can be located : Start > Programs > accessories
    Copy everything shown between the lines below.
    Paste into Notepad.
    Save as '''userChrome.css''' - note the spelling (edit updated - this was a typo error)
    This should be saved in the '''chrome''' folder.
    see second image below.
    Restart Thunderbird.
    I have chosen a yellow for you
    <pre>
    #f6f58c = a yellow....it is a hex code for a colour.
    </pre>
    You can change it if required. Remember when updating anything in the profile folders, you must close Thunderbird first.
    More info on colours.
    * http://www.yourhtmlsource.com/stylesheets/namedcolours.html
    <pre>
    * Do not remove the @namespace line -- it's required for correct functioning
    @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
    /*Background colour for message list*/
    #threadTree > treechildren::-moz-tree-row {
    background-color: #f6f58c !important;
    </pre>
    -------------------------------------------

  • How can i change my background color in "albums" mode back to black in iTunes 11

    how can i change my background color in albums mode back to black in iTunes 11?

    Themes work in Thunderbird - duggabe was not refering to Firefox.
    Another useful addon is theme and font changer:
    * https://addons.mozilla.org/fr/thunderbird/addon/theme-font-size-changer/
    However, Thunderbird allows you to modify all sorts of things.
    Make hidden files and folders visible:
    * http://kb.mozillazine.org/Show_hidden_files_and_folders
    Help > Troubleshooting Information
    Click on 'show Folder' button
    a window opens shwoing profile folder name
    Close Thunderbird now - this is important
    In the profile name folder, Create a new folder called '''chrome''' - note the spelling
    It should be in the same place as the 'Mail' folder.
    see first image below.
    Open Notepad
    Can be located : Start > Programs > accessories
    Copy everything shown between the lines below.
    Paste into Notepad.
    Save as '''userChrome.css''' - note the spelling (edit updated - this was a typo error)
    This should be saved in the '''chrome''' folder.
    see second image below.
    Restart Thunderbird.
    I have chosen a yellow for you
    <pre>
    #f6f58c = a yellow....it is a hex code for a colour.
    </pre>
    You can change it if required. Remember when updating anything in the profile folders, you must close Thunderbird first.
    More info on colours.
    * http://www.yourhtmlsource.com/stylesheets/namedcolours.html
    <pre>
    * Do not remove the @namespace line -- it's required for correct functioning
    @namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
    /*Background colour for message list*/
    #threadTree > treechildren::-moz-tree-row {
    background-color: #f6f58c !important;
    </pre>
    -------------------------------------------

  • Slice transparency on save single slice / background color for artboard

    Hi,
    I know, I am missing something obvious in Illustrator CS5 here:
    - how do I set the transparency for a slice(e.g. for a red background color)?
    - how do I set the background color for a particular artboard?
    Greetings
    Michael Kastner

    1. differs depending on the format you want to export. For GIFs, use "Save for Web and Devices"
    2. Draw a rectangle on the artboard in the desired color.

  • How do I add a background color to a document in Pages?

    How do I add a background color to a document in Pages?  I have made an invitation, with a photo in it, the text is in color, and I want to make the background pink instead of white.  thanks

    whoops sorry figured it out thanks!

  • How can I change fullscreen background color, so that it is the same when viewing on mac and iPad? I want this to be able to use MathType in widget text.

    How can I change fullscreen background color, so that it is the same when viewing on mac and iPad? I want this to be able to use MathType in widget text.
    As an example, html widget has white background on iPad, and black on mac. The same goes for interactive widget.
    The MathType text inserted is inserted as a image, and will have the same color when in fullscreen as when not. So I need the textcolor to be the same in both views. Anyone know how to fix this?

    We're still not communicating. This is why I wanted an example .iba.
    Here's a re-creation of my own, going off what you described. You said "all html widgets and all gallery widgets" have this problem. So I inserted a blank HTML widget and a blank Gallery widget, and typed into both. Inserted a MathType equation into both. I don't see any difference when I preview it on my Mac compared to the preview on the iPad. I want to help, but I can't help if I can't duplicate the issue.
    I've attached the screen shots and the .iba file [link to .iba file].
    Feel free to email me directly at bobm at dessci dot com. If you're uncomfortable giving some information here, tell me anything you want in email. I work for the "MathType company", Design Science.

  • How do I change the background color of a row in a table indicator?

    Hello,
      How do I change the background color of a row in a table indicator? I know how to change the background color in a active cell, but that is not what I want. My first intent is to make the background color of the first row a unique color, such as green, just to highlight the top row of the table.
    Regards,
    Kaspar
    Regards,
    Kaspar

    I have done this before by using a for loop to change the active cell of a row in order to give the appearance that the whole row is turning the color at once.
    CLA, CLED, CTD,CPI, LabVIEW Champion
    Platinum Alliance Partner
    Senior Engineer
    Using LV 2013, 2012
    Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.

  • How do I change the background color of a poster in pages?

    How do I change the background color using pages for ipad?  I am working with a poster template.

    I have done this before by using a for loop to change the active cell of a row in order to give the appearance that the whole row is turning the color at once.
    CLA, CLED, CTD,CPI, LabVIEW Champion
    Platinum Alliance Partner
    Senior Engineer
    Using LV 2013, 2012
    Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.

  • How do I change the background color of my canvas in FCPX?, How do I change the background color of my canvas in FCPX?

    How do I change the background color of my canvas in FCPX? I changed it from black to checkered but would like to return it to it's orginal settings.
    Thanks

    You can change the background display color in the playback preferences, either black, white, or checkerboard. This does not change the output color. If you want to add a color to the video, you have to place a custom generator underneath your video and change the color in the inspector.

  • How do you change a background color in Lightroom 4.4 ?

    Hi ..please how can you make a background color change in Lightroom 4.4  ?@

    If you are talking about the surrounding background of the photo while in Library Loupe View or in Develop, that you can select among 3 levels of gray, black or white in the Preferences / Interface settings.
    If you are talking about the photo itself, you need to be a bit more specific about what you'd like to do.

  • How do you change the background color?

    I saved a Word document as a PDF and the background color is yellow. The Word document is white. On the PDF, the background is yellow and the inserted graphics and boxes are white.
    How do I change the background color of the PDF? And is there a default setting for the color. This happens every time I need to create a PDF from a Word document.
    Thank you.
    Michele

    Hi Michele,
    Please check the following Preferences:
    Go to Edit -> Preferences -> Accessibility -> make sure "Replace Document Colors" is unchecked.
    Regards,
    Anoop

  • How do you change the background color from black to another color on i movie

    How do you change the background color from black to another color on i movie

    You post your question in the iMovie forum.

  • How do you change the background color not of the video clip, but the background the clip is on?

    How do you change the background color upon which the clip resides...
    I don't want to change anything within the clip itself, but the matte(?)
    from black to white or cream.
    I am working with Elements 10...

    Create a color matte of the desired color and place it on video track 1.  Then place your video on track 2.
    from here: Adobe Premiere Elements Help | Creating specialty clips
    Create a colored matte for a background
    You can create a clip consisting of a full‑frame matte of solid color, which you can use as a solid background for titles or animated clips.
    Brightly colored mattes can serve as temporary backgrounds to help you see transparency more clearly while you adjust a key effect.
    Click Project Assets. 
    In the Project Assets panel, click New Item from the panel options and choose Color Matte. 
    Choose a color in the Adobe Color Picker dialog box, and click OK. 
    A color matte clip is placed into both the Project Assets panel and the Expert view timeline.

Maybe you are looking for