How to bind to SystemColors in Silverlight?

222 Views Asked by At

I am not sure what will be the best techinique. I set references to system colors in App.xaml.cs.

 App.Current.Resources.Add("ActiveBorderColor ", SystemColors.ActiveBorderColor);

and bind it this way:

<TextBlock Text="TextBlock" Foreground="{StaticResource ActiveBorderColor}" />

It works but I am getting error that the 'ActiveBorderColor' resource could not be resolved. It is not perfect solution. I am wondering what is the correct way to do it. Any ideas are highly appreciated. Thank you.

1

There are 1 best solutions below

0
On

I think what you want to do is to define a static helper class. You can then get the SystemColors through XAML by referring to it. We did this on a project and it works well. Here's a quick example:

http://forums.silverlight.net/p/120976/289606.aspx

Be aware that the Silverlight version of the SystemColors class doesn't surface all the SystemColors! You'll be missing a few compared to what you get in WPF.

(sorry for taking so long to realize my code didn't paste. put in a link instead)