SL: Where TF are the Brushes??

Holy Smokes! A SilverLight post???!!!

Yes - I've entered the SilverLight realms... so far so good - one app is nearly ready for release (internal only) and I have to say the experience has been pretty good. I've had a couple of issues - mainly down to the fact that I'm not sure about some things - Cross Domain Policies for example... but on the whole it's been ok...

One of the things I did struggle with was the programatic setting of brushes, for example, say I wanted to set the Foreground property on a dynamically generated control in WPF, I would do:

control.Foreground = Brushes.Red;

So... In SL I tried this, but alas - Brushes is defined in 'System.Drawing' - which isn't part of the SL client code... ah... erm

So far, the only way I've found to achieve what I want - is to define the colours in the App.xaml (or indeed the local file themselves):

<SolidColorBrush x:Key="Colour1" Color="Red"/>

And access it:

control.Foreground = App.Current.Resources["Colour1"] as Brush;


I have yet to find any 'Brushes' like class in SL...

Does it exist? (Do I need it??)

Print | posted @ Tuesday, November 4, 2008 4:50 PM

Comments on this entry:

No comments posted yet.

Post A Comment
Title:
Name:
Email:
Comment:
Verification: