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. .NET (Core and Framework)
  4. Visual Studio Created Data Source and WPF

Visual Studio Created Data Source and WPF

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpwpfdatabasevisual-studioquestion
3 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
    Dexterus
    wrote on last edited by
    #1

    I am trying to bind a ListView/TreeView w/e to a Data Source I've created from Visual Studio for the project and would like to know if and how it would be possible to bind solely using XAML. As an idea, let's say we have appName, appName.dataSetFromMySQLviaODBC as the data set, with tableAdapter and tableColumn as the only column, any way to, using only XAML, no cs code that's "user" written, bind the data there to a ListView? And if it's not too much of a stretch, considering it's probably quite easy to find if I poke around, anything special to do to make the data update in the ListView mirror the database changes? Or is it at least possible?

    D 1 Reply Last reply
    0
    • D Dexterus

      I am trying to bind a ListView/TreeView w/e to a Data Source I've created from Visual Studio for the project and would like to know if and how it would be possible to bind solely using XAML. As an idea, let's say we have appName, appName.dataSetFromMySQLviaODBC as the data set, with tableAdapter and tableColumn as the only column, any way to, using only XAML, no cs code that's "user" written, bind the data there to a ListView? And if it's not too much of a stretch, considering it's probably quite easy to find if I poke around, anything special to do to make the data update in the ListView mirror the database changes? Or is it at least possible?

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      My knowledge of WPF is quite limited, having only looked into it in the last two weeks. But, from what I've found, using ODBC as a data source, no, you cannot do this using only XAML. I think you need to provide the code to grab the data so the XAML has something to bind to. I could be wrong though... By the way, using ODBC is quite pointless if your using SQL Server. Use the SQL Server specific provider if you want your SQL code to run faster and offer more flexibility.

      Dexterus wrote:

      anything special to do to make the data update in the ListView mirror the database changes?

      Only if you have code that goes and gets the changes. Youe code doesn't automagically know that the database has changed without it changing it itself.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      D 1 Reply Last reply
      0
      • D Dave Kreskowiak

        My knowledge of WPF is quite limited, having only looked into it in the last two weeks. But, from what I've found, using ODBC as a data source, no, you cannot do this using only XAML. I think you need to provide the code to grab the data so the XAML has something to bind to. I could be wrong though... By the way, using ODBC is quite pointless if your using SQL Server. Use the SQL Server specific provider if you want your SQL code to run faster and offer more flexibility.

        Dexterus wrote:

        anything special to do to make the data update in the ListView mirror the database changes?

        Only if you have code that goes and gets the changes. Youe code doesn't automagically know that the database has changed without it changing it itself.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007

        D Offline
        D Offline
        Dexterus
        wrote on last edited by
        #3

        Eh, tried to do something fast-ish so I used what I had, an ODBC connection string :) My WPF experience extends to today and the examples I've found around about this DB binding were pretty much using the same thing, a DataSet. So either I have not found the correct one that VS creates when I create a Data Source (code it auto-magically created to work that data source was slightly hard to read) and I should use as Provider or maybe context or it simply doesn't create a DataSet instance. This last thing would mean it turns into the same, initialize connection, get and fill that all examples I've found do, only they do it a lot cleaner than the "wizard" way. As for the auto-update was thinking maybe data sources would have some sort of flag or something that would signal the change and it auto-update based on that and someone would know about that. It's not an issue though, manual labor works also. PS: Would there be a better place for this post? As this is my first one I am somewhat unfamiliar with the exact structure. Switching to another board would keep this one clean of unrelated stuff and make my question slightly more visible to people that spend more time browsing that other board.

        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