在WPF中使用DataGridCheckBoxColumn。 [英] Using DataGridCheckBoxColumn in WPF.

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

问题描述



WPF新手。我正在使用DataGrid,它从数据库中填充数据。我还为复选框包含了一个DataGridCheckBoxColumn。现在我想要复选框的选中值。我怎么知道,复选框是否被选中。如果选中相应的复选框,我想对我的数据库进行更改。您可以建议一个解决方案。



谢谢和问候

raj_arenem

Hi,
Am new to WPF. Am using a DataGrid, which populates data from the database. I have also included a DataGridCheckBoxColumn for the checkbox. Now i want the checked value of the checkbox. How can i know that, the checkbox is checked or not. If the corresponding checkbox is checked then, i want to make changes to my database.Can you please suggest a solution.

Thanks & regards
raj_arenem

推荐答案

如果您要遵循MVVM,一种解决方案是将您的数据库对象(数据集/表)包装到模型中,将模型包装到视图模型并将该视图模型的可观察集合绑定到网格的ItemsSource。然后,一旦更改了该复选框的值,就可以在绑定文本框的属性的setter中捕获它,从那里可以更新模型,直到数据库。
If you''re going to follow MVVM, one solution is to wrap your DB objects(dataset/table) into a model, wrap the model to a viewmodel and bind an observable collection of that viewmodel to the ItemsSource of the grid. Then once you change the value of that check box, you can catch it in the setter of the property where you bind the text box, from there you can update the model, down to the database.


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

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