Visual Studio Created Data Source and WPF
-
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?
-
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?
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 -
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, 2007Eh, 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.