“全选”复选框一个WPF DataGrid中,其中的复选框已经有一个源? [英] 'Check All' checkbox for a WPF DataGrid, where the checkboxes already have a source?

查看:363
本文介绍了“全选”复选框一个WPF DataGrid中,其中的复选框已经有一个源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个WPF DataGrid中有复选框列。这些复选框已绑定到其他数据源。我们需要的是为每一个检查柱的复选框/取消选中所有复选框(并因此更新数据源,使所有的值相同)。

There is a WPF DataGrid with columns that have checkboxes. These checkboxes are already bound to some data source. What we want is a checkbox for each column that checks/unchecks all the checkboxes (and as a result updates the data source so that all the values are the same).

现有的解决方案,在这里工作,如果没有一个现有的数据源 - 但我们必须有效地二,全选,在行其他复选框绑定到复选框和实际数据,如果是有道理的

Existing solutions on here work if there isn't an existing datasource - but we have effectively two, the 'select all' checkboxes and the actual data that the other checkboxes in the rows are bound to, if that makes sense.

如果我们可以使用触发器或诸如此类,而不是落后code',这将是理想的。是否有一个声明的解决方案?

If we could use a trigger or somesuch instead of 'code behind' that would be ideal. Is there a declarative solution?

推荐答案

请您复选框的Click事件指向您的视图模型迭代访问您的数据源和集合器isChecked为true。命令

Make your CheckBox's Click event point to a Command in your ViewModel that iterates your DataSource and sets IsChecked to true.

这篇关于“全选”复选框一个WPF DataGrid中,其中的复选框已经有一个源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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