views:

675

answers:

4

I'm having real difficulties with XAML files in Silverlight since they get very big very fast when using Blend. It just becomes a wall of text after only a handful of controls are added and animated.

I'm hoping a better vesion of Blend will come out soon, so that our designers will never even have to see XAML. For now, though, that is not a solution - XAML still needs to be managed manually and it is a depressing task.

Has anyone found a solution to this? How do you keep your XAML files in order? How do you understand them when they get big?

Edit: I am especially interested in Silverlight solutions, since the most obvious WPF solution - splitting things up into resource dictionaries - is not supported in Silverlight.

+10  A: 

It does require a little bit of work to maintain XAML files, but basically, what you need to do is split them up in resource files (XAML Resource Dictionaries) using a scheme that makes sense to you.

For example we use a scheme where we have a folder structure like this:

  • Resources (contains XAML Files that represent the user controls and pages)

    • Stencils (XAML files with Shapes)
    • Styles ( XAML Files with styles)
    • Brushes ( ... )
      • Shared
    • Templates ( ... )

Your structure might vary but, separating all resources in different files really makes maintenance more easy in the long run.

Pop Catalin
+1  A: 

I'm a Creative Developer and work in Blend extensively.

I published a few thoughts last year on keeping XAML clean.

Silverlight currently does not support MergedResourceDictionaries so it's hard to break out the XAML into separate ResourceDictionary files as I suggested in another post.

Paul Stovell also has some interesting guidelines for XAML.

Alan Le
+3  A: 

I have been using Silverlight 2 since January when it was in private release, and we ran into this problem, all our XAML was in one big file. What we did as best practices was to break up the user interface into separate user controls based on visual categorization (header, footer, navigation controls etc..) Originally we tried to use nested canvases (grids had not been added to the framework yet) and this turned into a maintenance nightmare later.

In Blend you can actually select a Canvas/grid etc... from the Objects and Timeline window, right click on it, and you are given the option "Make Control.." This made for speedy re factoring and modularizing our main XAML file. We then used Events to allow the user controls to communicate between each other.

Hope this helps, and good luck!

FireWire