DZone
Mobile Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Mobile Zone > Color Reflector for WP7 and Silverlight

Color Reflector for WP7 and Silverlight

Punit Ganshani user avatar by
Punit Ganshani
·
Dec. 23, 11 · Mobile Zone · Interview
Like (0)
Save
Tweet
5.11K Views

Join the DZone community and get the full member experience.

Join For Free

Let’s assume that you have a paint application.  A user can draw, modify pictures, save it, retrieve it back and even share it.  Now with such an application, you would want to enhance the user experience by allowing him customize the user-interface.  So user changes the background color, fonts, etc and closes the application.

Next day, he opens the application and he expects that his settings are saved.  You would definitely use IsolatedStorage to save his data in a local XML file.  And then, apply the colors, fonts to the UI.  Here’s where you need a Color Reflector that converts a color (in a String format) to a Color (as in Enum)

So, here you go for the ColorReflector

using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Shapes;

namespace OptimaX.WP7.Formatters
{
public class ColorReflector
{
public static Color FromKnownColor(string colorName)
{
Line lne = (Line)XamlReader.Load("<line xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Fill="" + colorName + "" />");
return (Color)lne.Fill.GetValue(SolidColorBrush.ColorProperty);
}
}
}

What is OptimaX.WP7?  That is my own-framework with all utilities/tools for Windows Phone 7


Source:  http://www.ganshani.com/2011/06/11/color-reflector-for-wp7-and-silverlight/


application Windows Phone User experience Data (computing) Strings Convert (command) Data Types XML

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Container Orchestration Tools Comparison
  • Pattern Matching for Switch
  • Datafaker: An Alternative to Using Production Data
  • My Sentiments, Erm… Not Exactly

Comments

Mobile Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo