Archive for the ‘Silverlight 3’ Category.

How To Create a Flexible Striped Gradient In Silverlight and WPF

Thanks to Joe McBride and Jason Alderman, who discovered this technique in some of Microsoft’s theme packs.

I’m trying something a little new… I’m going to post all future Silverlight tutorials on CodeRun, an online IDE. Basically, just follow the link below and click “Run” and you’ll see this in action. You can change the XAML at CodeRun to test it out, which I find exceptionally cool. Let me know if you a) like this or b) hate this.

Open this project on CodeRun.

This is just a little trick to get a nice flexible striped gradient in Silverlight or WPF. Our end product will look like this

clip_image001

Zoomed in:

clip_image001[5]

Just adds some nice texture to the app.

First, go to the element you want to apply the gradient to and go to the (you guessed it!) gradient section in the background.

clip_image001[7]

This will pull up the default black-to-white gradient that we all know and love. Give it two more gradient stops as close to the center as you can by clicking on the gradient twice. Make the two left stops the color of your stripe. For this example, I’m using a nice blue gradient with some transparency. I think it fits nice with the background. Also make the two right stops fully transparent. Should look something like this:

clip_image001[11]

Dandy. Now click on the arrow to expand our options (seen at the bottom of the image above) and a new set of options open up for us to futz with. Let’s go ahead and set the following options:

  • StartPoint = 0,0
  • EndPoint = 1.5, 1.5
  • MappingMode = Absolute
  • SpreadMethod = Repeat

clip_image001[13]

And that’s it! We can change the visible color to get something a little more appropriate to our background or we can change the EndPoint to make the stripes wider or at a different angle. But that’s all we need.

Here’s the XAML for reference.

<LinearGradientBrush
EndPoint=”1.5,1.5″
MappingMode=”Absolute”
SpreadMethod=”Repeat”
StartPoint=”0,0″>
<GradientStop Color=”#BF125881″/>
<GradientStop Color=”#BE6C9AE0″ Offset=”0.526″/>
<GradientStop Color=”Transparent” Offset=”0.544″/>
<GradientStop Color=”Transparent” Offset=”1″/>
</LinearGradientBrush>

Silverlight Visualization of MIX10 Open Call Sessions

I was digging through all the sessions submitted for the MIX10 Open Call last week and I decided that there had to be a better way to browse through the data to find sessions that might be interesting. So I spent the weekend hacking together this Silverlight visualization of the MIX10 Open Call sessions.

If you think this is an engaging way to look at the Open Call sessions, I ask that you include my session “Creating Effective Info Viz in Silverlight” on your ballot.

MIX10OpenCallImage

If you have any problems with this project, please let me know! I’ve already had one person point out a parsing error that was depriving him of a properly attributed session.

This visualization is basically a set of word clouds for the titles, abstracts and speakers of the submitted proposals. Clicking on the words or names brings up a list of related sessions with links so that users can either go to the session or directly vote for it (although you’d still need to click  “Submit Your Ballot” in order to make the vote count).

So, now I’d like to talk about problems with this project.

There’s a weird problem with the animation when the panels flip from front (the word cloud) to back (the detail view). I think this is because I’m building the detail view dynamically, which makes it mostly a performance issue. I spent a couple hours fighting with this problem and tried several possible solutions. Ultimately, I couldn’t fix it, so I decided not to let the perfect be the enemy of the good.

I decided to use a wrapping ListBox for displaying all the words and names rather than try to squish them onto a single screen for a couple reasons.

  1. Dumping all the sized items into a ListBox was WAY easier that constructing a beautiful Wordle type word cloud and gave me most of the value. Since there was a very short window in which this project would be valuable, I decided in favor of the faster method.
  2. If the user is trying to play around with this and doesn’t want their browser to fill the screen, they can still see everything. Allowing scrolling means that the user doesn’t have to feel like I DEMAND their full attention. The application becomes a casual application rather than a consuming one.
  3. People love to see their names in lights. Over on the “Speaker” section, I wanted the names to be big enough so that every person who submitted a session could see their name in the “Speaker” panel. That was probably the most important part of this project to me (hey, I do user design… it’s all about the people), so that’s what I did.

Given more time, I probably would have worked a little more on the visual design and the motion design (animations and what not). I probably also would have sped up the application by taking some of the processing procedures out of the application and turned them into static data files. The fact of the matter was that this project evolved from testing to prototype to final project very quickly because of the time constraints.

But, hey, that’s life.

Info Vis, Snapping Behaviors, Illustrator Guidance and Custom Control Stuff

I’ve been a busy blogger over at Veracity Blogs the last couple weeks. Here’s a list of my new posts:

  • Florida Crime Rate Visualization – My attempts to use Silverlight for information visualizations are going pretty well. In this post, I visualize the Florida crime rate by county over almost 20 years. There are project files availalbe for anyone who wants to dig into how I did it a little more.
  • Adobe Illustrator to XAML Conversion Options – This post walks through the pros and cons of two methods for taking an SVG file (or Adobe Illustrator) file and pulling it into Blend as a XAML file. It also has a XAML copy of a vector map of the US by county for download.
  • Create A Snapping Slider In Blend Using Behaviors – This provides a downloadable behavior for getting a slider to snap to integers (or an integer multiple based on certain settings). I’ve provided project files as well as a tutorial for how to do it.
  • How To Create a PART in Your Silverlight Custom Control – Because there are about a dozen tutorials on building a custom control, but I keep forgetting exactly how to do this part of it.
  • How To Animate a Changing Property in a Custom Control in Silverlight – Have you ever wanted your property to animation automatically when it changes in your Silverlight Custom Control. I say, “Who hasn’t!?” at which point my wife forces me out into the fresh air and sunshine (or, as I call it, the Blinding Day Star). After I scurry back inside, I wrote this blog post.
  • How To Build a Storyboard Animation for Silverlight in C# – Because sometimes you want to enjoy the benefits of the Silverlight animation engine but you really need to build the animation in the code instead of the XAML.

WPF, Silverlight and Design Links for 09/08/09

I finally cleaned out my Google Reader list and picked out the stuff I like.