I'm a novice programmer and I've been doing it more as a hobby then a career. As such I'm putting together an application for generating invoices for company I work for. I have the invoicing stuff working which takes in data feeds from our suppliers and matches up customers, products and rates etc. and produces the invoices. I'm now trying to pretty it up and allow for the customer and rate details to be edited. Part of that means I've got a number of tables that hold lookup values, e.g. VAT rate, mark up value, custom rates.
I'm writing the application in WPF, C#, .Net 4. I'm also trying to keep to the MVVM pattern for separating the layers.
I've created a generic VeiwModel called EditLookupTableViewModel which handles talking to the data layer and all the rest. My problem is with the View. I would like to create a single view that can handle all the data types that I allow on the above class. The bit I'm stuck on is this.
I would like to present the data as a list of the current values in the database table and allow people to edit those values, or add new values. The various data types are all based on tables in an SQL database being access via Entity Framework 4. The tables do not all have the same number or type of columns.
If I present the data as a list using a DataGrid control, how do I change the column types based on the data type being displayed?
I've been searching on various sites but have not found anything that fits.
I thought I'd be able to user a DataTemplate and then use a DataTemplateSelector but I don't see any way of creating a DataTemplate for a DataGrid.
I then thought I'd use a ContentPresenter but I can't see how you'd select the template.
Ideally I would like to use some kind og TemplateSelector as I could then control the template from code as several tables have the same structure and so it would be great to reuse the template for those tables that are the same.
Any help would be much appreciated as I'm sure there must be a more elegant solution than creating multiple views.
Thanks
Simon