Home Contact

X

Coder, not artist.

News

Current archive is at: http://cskardon.wordpress.com/ - I aim to move it all soon! All code on here is free, but as a consequence it's up to you to check it, ha! If you have any questions, feel free to email: cskardon -- @ -- xclave dot co dot uk I'm sure you can decrypt the address there!

Twitter












Archives

Post Categories

Image Galleries

Syndication:

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??)

Feedback

No comments posted yet.


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