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.