使用MVVM的Wpf Datagrid [英] Wpf Datagrid using MVVM

查看:186
本文介绍了使用MVVM的Wpf Datagrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

假设我有一种形式的Datagrid,可以.

Assume I have a Datagrid in one form ok.

能够在运行时将详细信息插入到Datagrid中(尽可能多的行,我们没有限制).

Am able to insert details into the Datagrid at run time (As many rows as we want no limit).

我也有保存按钮,但是现在没有任何代码.

I have save button also but now without any code.

现在我想将插入的详细信息(在Datagrid中)保存到数据库中.

now i want to save the inserted details (in Datagrid)  into database. 

对于一个数据库表中的每一列,我都有一个唯一的ID.

I have one unique Id for every column in one table of database.

现在,我想将插入的详细信息保存到另一个数据库表中,这样我就可以通过使用特定列的唯一ID来获取详细信息.

Now i want to save the inserted details in another table of database in such a way that i can get the details by using that unique id of particular column.

使用MVVM模式.

因此,如果您有任何想法,示例或解决方案,请寄给我.

So, Please send me any idea's , examples or solution if you have..

先谢谢了

克里希纳.

推荐答案

使用inotifypropertychaged接口在视图模型中创建一个ObservableCollection Type属性.

Create a ObservableCollection Type Property into your viewmodel using inotifypropertychaged interface.

将此属性绑定到您的数据网格中.

Bind this property into your datagrid.

现在,当您在datagrid中插入行时,它会自动将一行添加到observalecollection属性中.

Now When you insert rows into datagrid, it automatically add one rows into observalecollection property.

现在,您可以使用此属性获取插入的行.

Now you can use this property to get inserted rows.

 

谢谢

Rajnikant

Rajnikant

 


这篇关于使用MVVM的Wpf Datagrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆