Old school WPF syntax revisited…. GradientBrushes

Remember this syntax from the early days of Avalon/WPF/XAML?

<Rectangle Width="300" Height="200"
    Fill="HorizontalGradient Blue White" >
</Rectangle>

Very simple — easy to create Gradient Brush. But, it was removed from Avalon/WPF in part due to it’s challenge for tools (parsing, etc.).

Mike posts a simple MarkupExtension that although it doesn’t mimic the old syntax identically, the spirit is there.

<Rectangle Width="300" Height="200"
  Fill="{local:RadialGradientBrush red, blue}" />

Technical Interview Question #2

Interview Series

I have an array. I need the array’s element order randomized.

So, if I have an array like this:

a[0] = "abc"

a[1] = "def"

a[2] = "ghi"

a[3] = "jkl"

 

It might be randomized like this:

a[0] = "jkl"

a[1] = "def"

a[2] = "abc"

a[3] = "ghi"

 

You’re provided with a function which returns a random number between 0 and N, where N is the number you provide as a parameter.

As always, your solution should execute quickly and be efficient.

Silverlight 2.0’s Resources … not the same as WPF… :(

I’ve been wanting to post something about the differences between WPF and Silverlight’s handling of Resources, but this was just posted at LearnWPF. A nice summary worthy of a quick read if you’re not already familiar with the differences.

It’s too bad that there isn’t better feature/behavior parity between WPF and Silverlight 2.0 — if for no other reason than making it easier to learn both platforms. The things that make WPF powerful are often absent, so you need to create your own techniques. If you’re trying to share UI or code — that means a watered-down version of your code is being used in WPF. So much is missing right now, only the code-behind might be portable. Even that may require some refactoring.

I find this chain on the Silverlight forums interesting — at least to see what others find important.

Silverlight 3.0 will hopefully be the sweet spot for most developers. 2.0 — it’s a great start, especially if you’re starting from scratch — but requires some rethinking if you know WPF.

Is there anything you would have left out of Silverlight 2.0 to get your "favorite" feature added?

My #1: I would have ditched any support for dynamic languages. Learning a new language isn’t that hard — and it’s clear that learning Javascript hasn’t prevented millions of developers/hackers/hobbyists from creating interactive web pages.

Wireless Shutter Release for the D300

imageI just bought a wireless shutter release for my D300, purchased from Gadget Infinity for $30 US. There are models for a few different cameras and manufacturers.  It’s nice for a few reasons: it’s radio based rather than IR based (ALTHOUGH it’s my understanding that in some countries, it’s illegal to use certain radio transmitters that aren’t licensed, so BEWARE), it’s SIGNFICANTLY cheaper than the equivalent IR based system from Nikon, and finally it’s cheaper than the same product, relabeled as another manufacturer that is available in many camera stores. I saw a similar product in a local camera store for $100 US. It was the exact same product, yet it was $70 more expensive!

It claims 30m distance for use, but I’ve only tested it at about 30 ft — and it worked fine. If I ever test it at greater distances, I’ll post an update here.

Gadget Infinity which is based in Hong Kong, shipped the product the next business day after I placed the order airmail, and it came in about 10 days.