Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Learning WPF basics - how to create & use (and re-use) a combobox 'template' bound to CONSTRAINed SQL columns

Learning WPF basics - how to create & use (and re-use) a combobox 'template' bound to CONSTRAINed SQL columns

Scheduled Pinned Locked Moved WPF
csharpdatabasesql-serverwpfsysadmin
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Duke Carey
    wrote on last edited by
    #1

    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?

    P 1 Reply Last reply
    0
    • D Duke Carey

      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?

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      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.

      My blog | My articles | MoXAML PowerToys | Onyx

      D 1 Reply Last reply
      0
      • P Pete OHanlon

        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.

        My blog | My articles | MoXAML PowerToys | Onyx

        D Offline
        D Offline
        Duke Carey
        wrote on last edited by
        #3

        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.

        P 1 Reply Last reply
        0
        • D Duke Carey

          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.

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          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.

          My blog | My articles | MoXAML PowerToys | Onyx

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups