A Better Browsing Experience: Listing 4.

Replacing default colors with theme colors.

scriptToRun = scriptToRun.Replace("BGColor", FetchBackgroundColor());
scriptToRun = scriptToRun.Replace("FGColor", FetchFontColor());
Browser.InvokeScript("eval", scriptToRun);

private string FetchBackgroundColor()
{
  return IsBackgroundBlack() ? "#000;" : "#fff";
}

private string FetchFontColor()
{
  return IsBackgroundBlack() ? "#fff;" : "#000";
}

private static bool IsBackgroundBlack()
{
  return BackGroundColorResource == "#FF000000";
}

private static string BackGroundColorResource
{
  get
  {
    var mc = (Color)Application.Current.Resources["PhoneBackgroundColor"];
    string color = mc.ToString();
    return color;
  }
}

About the Author

Nick Randolph runs Built to Roam, a consulting company that specializes in training, mentoring and assisting other companies build mobile applications. With a heritage in rich client applications for both the desktop and a variety of mobile platforms, Nick currently presents, writes and educates on the Windows Phone platform.

comments powered by Disqus

Featured

Subscribe on YouTube