views:

102

answers:

1

I am working on a typical data entry system in Silverlight. Most of my screens are basically view/edit screens. I am using a DDD approach and have domain objects for everything. A typical scenario is something like a User object with a user edit and entry page.

After working on this for a few types of objects, I am seeing a pattern. I am creating a view that does nothing but binds to the domain object. Each view has a similar look with a header (bound to the domain object), and some edit controls based on the data type of the view (check box for bool, lots of text boxes, etc).

So I'm thinking, instead of creating a separate view for each class, I could create some sort of generic View class that auto generates a form based on the object in the DataContext. I could somehow tell the View what order to place the fields (i.e. First/Last name is on top, then phone, then address, etc...), and also give some attributes to the fields (such as setting First/Last name as a header which will be shown in bold or something). To me, this sounds similar to what you do with CSS. Then to change the look of the entire application, I just have to change the View or the template for the View.

So here are my questions:

Does this approach make sense and would it work?

Is there anything like this already?

If not, what would be the best way to do it?

+1  A: 

Before you go ahead with this you should take a peek at the Dataform control in the Silverlight 3 beta. You might find you are re-inventing the wheel.

AnthonyWJones
That's the coolest thing ever.Here is a good video showing this in detail:http://download.microsoft.com/download/6/0/D/60DB2C5B-DB11-484F-9D0B-4ABA8EB04DA2/winvideo-DataForml.wmv
NotDan