Home > SURFACE > Adding Custom Color to your Surface Contacts

Adding Custom Color to your Surface Contacts

Sometimes it is is good to know also simple things under the cover that you would have never though to add to you app until a customer raise that question. The source of the issue was the fact that customer application background was build with quite light colors range and he was simply asking that it could be nice to be able to change the contact color on your surface application.

As all of us may know, for us it might be a useless thing but what customer want customer have.

So for those who want to provide the abilities to affect that contact colors here what you should do.

For that I will use a cool way which will differe from traditionnal code behind approach, instead will use direct binding:

  • Define a ressource entry of type string and name it ContactColor
  • Provide as a string value the exemple of #FFFFFF ( correspondign to White color)
  • From your main window xaml file add the following xaml name space :xmlns :props=”clr-namespace:MyApplication.Properties;assembly=MyApplication”
  • Enter the following line to your windows:TouchVisualizer.VisualizationColor1=”{Binding ContactColor, Source={x:Static props:Settings.Default}}” s:TouchVisualizer.VisualizationColor2=”{Binding ContactColor, Source={x:Static props:Settings.Default}}” s:TouchVisualizer.VisualizationColor3=”{Binding ContactColor, Source={x:Static props:Settings.Default}}”>

ContcatColor notify property is populated as follow from code behind :
/// The name of the visualization color setting in the config file.
private const string _ContactColorSetting = “NameOfressourceKey”;

System.Drawing.Color tempColor = System.Drawing.ColorTranslator.FromHtml(GetSetting(_ColorSetting, defaults));
ContactColor =Color.FromArgb(tempColor.A,tempColor.R, tempColor.G, tempColor.B);

An that’s it.

What this binding does is reading the value of the ressource property ContactColor which is bind to a ViewModel property ContactColor of my application and associate that color to each visualizer. By placing that color in a ressource, you can provide an easy way to access it through a configuration tool.

For more inofrmation on TouchVisualizer

A simple thing, will cool effect on your final app

Hoping you will find it interresting

Categories: SURFACE Tags: , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: