Learning WPF basics - how to create & use (and re-use) a combobox 'template' bound to CONSTRAINed SQL columns
-
I'm trying to learn WPF doing some simple stuff before tackling a real project. The first thing I've tried to do is to mock up an Excel sheet used to review case files. It uses 40 some columns to collect reviewers' input. At least 5 columns use the same Excel data validation to limit the responses to: Yes, No, or Unknown So..in porting this to SQL Server I've put check constraints in that require one of those 3 entries. In mocking up the data entry form in WPF I would like to use a combobox that IS BOUND to one of those SQL columns and offers the 3 permissible choices. It seems to me that the ideal approach would be to create a template combobox with the 3 choices, and then use and re-use the template for each of the constrained columns. Maybe my searching skills are poor, but I can't seem to find any explanations or examples of doing something like this, even though it seems as though this sort of thing would be used often. Where do I start?
-
I'm trying to learn WPF doing some simple stuff before tackling a real project. The first thing I've tried to do is to mock up an Excel sheet used to review case files. It uses 40 some columns to collect reviewers' input. At least 5 columns use the same Excel data validation to limit the responses to: Yes, No, or Unknown So..in porting this to SQL Server I've put check constraints in that require one of those 3 entries. In mocking up the data entry form in WPF I would like to use a combobox that IS BOUND to one of those SQL columns and offers the 3 permissible choices. It seems to me that the ideal approach would be to create a template combobox with the 3 choices, and then use and re-use the template for each of the constrained columns. Maybe my searching skills are poor, but I can't seem to find any explanations or examples of doing something like this, even though it seems as though this sort of thing would be used often. Where do I start?
Normally, I'd approach this by using MVVM to bind to the items using a user control which contains the combo box, and the VM would contain the values (along with the validation). It's fairly straightforward, so I'd suggest that you have a read up on MVVM (that's Model View ViewModel).
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
Normally, I'd approach this by using MVVM to bind to the items using a user control which contains the combo box, and the VM would contain the values (along with the validation). It's fairly straightforward, so I'd suggest that you have a read up on MVVM (that's Model View ViewModel).
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
Pete - Thanks for the response. I have been reading up on MVVM, but my 'programming' background has mostly been Excel VBA and some basic/rudimentary WinForm apps. It's a big step to grasp the concepts behind MVVM.
-
Pete - Thanks for the response. I have been reading up on MVVM, but my 'programming' background has mostly been Excel VBA and some basic/rudimentary WinForm apps. It's a big step to grasp the concepts behind MVVM.
It is - but once you get it, it makes tasks like this so much simpler.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.