How can I bind a c#.net DataView (WPF) to a SQLite database?

心不动则不痛 提交于 2019-12-11 01:43:58

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!