问题
I am using the official System.Data.SQLite ADO.NET provider for my application, and I am trying to display the contents of a database in a WPF DataGrid. Currently I am able to select the data I need to display from the database, but I don't how to display that data on the datagrid.
I have search on the web, read blog posts, tutorials and guides, but to no avail. I am moving an application from a PHP system (using my local server) to a desktop application to be portable across systems. My current applications uses sqlite3 databases, and contains quite a few rows. This is why I would prefer to make sqlite work with c#, which is the desktop oriented language I am most comfortable with.
回答1:
You should just have to Bind the column to the name of the field in the db.
<local:AutoGenerateColumn Column="ItemStatusId"
Binding="{Binding Path=ItemStatusId}" />
Here's a link to a pretty good tutorial: http://www.codeproject.com/KB/WPF/DataGridAutoTemplate.aspx
来源:https://stackoverflow.com/questions/6419164/how-can-i-bind-a-c-net-dataview-wpf-to-a-sqlite-database