Silverlight DRY when animating multiple UserControls on main navigation page

Starting with Silverlight development. However, to read a good book Silverlight: Suggestions are welcome.

I have a main GUI screen in which 7 user controls (menu items) "swoop down" in sight, all in their own way. I have custom controls that are nicely separated and feel good. Having multiple storyboards (one for each menu item) with multiple keyframe animations (X, Y, height, width) in one .XAML doesn't sit well with me. The repetition of all these property values ​​is disgusting, insane.

I tried to move values ​​into app.xaml and set animation duration using style keys, but with limited success. Can anyone suggest a good way to make this cleaner? Reorganize storyboards to your own control? Property values ​​in resources? Building code dynamically?

Referring to a practical site is also good.

+1


a source to share


1 answer


You might be facing a XAML overload. It seems like most developers, starting with WPF or Silverlight, feel like everything has to go in XAML, which can go into XAML. Then they get to the point where they fight XAML to get something that could take moments in the code (I got into his problem too).

If you find something unwieldy or ugly in XAML, consider writing it in code. This is not a crime. You can perhaps declare one method to create your storyboard and then use it multiple times, or you can create a class that wraps your storyboard and adds multiple instances to the XAML in much neater ways. Since you got it right at the end of your post, there are several ways to make it cleaner, you just need to decide which one suits your situation.



Without some XAML example, it's hard to imagine the exact question you're facing, so I couldn't make a clear recommendation, but hopefully this helps. I love the sound of your on-board controls - the image I have in my head is really nice.

+1


a source







All Articles