views:

67

answers:

1

Hello all.

Starting with Silverlight development. Yet to read a good Silverlight book: suggestions welcome.

I have a main GUI screen where 7 user controls (menu items) 'swoop' into sight, all along their own path. I have the user controls nicely seperated and behaving well. Having multiple storyboards (1 each for each menuitem) with multiple keyframe animations (X,Y,height, width) in one .XAML is not sitting well with me. Repeating all those property values is hideous, neverthemind maintenance.

I've tried to move values into the app.xaml and set animation durations with style keys, but having limited success. Can anyone suggest a nice way of making this cleaner? Refactor the storyboards out to their own control? Property values in resources? Dynamic building in codebehind?

Referring me to a how-to site is fine as well. Tx!

A: 

You may be falling foul of XAML overload. It seems that most developers, when starting with WPF or Silverlight, feel everything should go into XAML that can go into XAML. They then get to a point where they're fighting with the XAML to get something done that would take moments in the code-behind (I too have hit his issue).

If you're finding something cumbersome or ugly in XAML, consider writing it in code. It's not a crime. You can probably declare a single method for creating your storyboard and then use it multiple times, or you could create a class that wraps your storyboard and add multiple instances into XAML in much neater ways. As you have quite rightly identified towards the end of your post, there are multiple ways to make it cleaner, you just need to decide which one suits your situation.

Without some example XAML, it's difficult to visualize the exact issue you face, so I couldn't make a distinct recommendation, but I hope this helps. I like the sound of your swooping controls - the image I have in my head is quite nice indeed.

Jeff Yates