R – How to manage huge and barely maintainable XAML files

expression-blendsilverlightwpfxaml

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.

Best Answer

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!

Related Topic