Help with program structure.
Hello I am working on a project to record data from multiple items and print them to paper worksheets. I have a working prototype done in Winforms, using a single type of worksheet, but the end result will need to use 3 types of worksheets. Each type of worksheet also has several variants (see first image) for a total of about 20 different worksheets. Also, each type and variant of worksheet requires some different data to be collected from the user. I am struggling on how to structure this correctly. Attempts I have tried so far seem to involve a lot of repetition which I would like to avoid doing 20 times. Can someone point me in the right direction on how to do this correctly?
Things to know:
I am using WPF/Caliburn Micro with MVVM pattern.
I have written several small but working programs over the last few years but still very much a noob.
I have include a few other diagrams of my planning process.
10 Replies
Could you create an abstraction for the fields and create a single form that takes a flexible number of fields and displays them generically?
create an abstraction for the fieldsBy this do you mean a create a class that holds the value of all possible fields?
A class that can be used to represent each field
Maybe each field is a different instance of the class with different params or data or whatever overloads
Ok, and instead of using xaml I just add the controls through code at runtime?
Yes
E.g. if a specific variant field needs different controls just add a virtual method so they can override what would be added at runtime
A class that can be used to represent each fieldclass GenericField { public object Value { get; set; } GenericField(object value) { Value = value; } } something like this?
If that's all the information you need it to have, yes
Then at runtime if user chooses Form 1a for example, I can add the needed controls and bind each one to an instance of the generic class. Do I just add these instances to a collection? Can you bind to items in a collection? Still fairly new to wpf and have been using CalibirnMicro to help with bindings.
You can bind to a collection, yes
It's been a while since I used WPF so I'm not sure about the specifics
Great. Thanks for the help. I think I have a good direction to focus my research.