WPF - 编程方式绑定到DataGridCheckBoxColumn [英] WPF - Programatically Binding to DataGridCheckBoxColumn

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

问题描述

我想为IList编程绑定到一个DataGrid和其中一列是一个布尔值,所以我决定用一个DataGridCheckBoxColumn,而不是我平常DataGridTextColumn的。不幸的是,这似乎并没有奏效。

I'm trying to programatically bind an IList to a datagrid and one of the columns is a boolean value, so I decided to use a DataGridCheckBoxColumn instead of my usual DataGridTextColumn. Unfortunately, this doesn't seem to be working.

我目前使用这个code:

This the code I am currently using:

DataGridCheckBoxColumn dgcbc = new DataGridCheckBoxColumn();
Binding b = new Binding("Convicted");

dgcbc.Header = "Convicted";
dgcbc.Binding = b;
this.dgResults.Columns.Add(dgcbc);

在我设置DataGrid的源复选框列显示出来,但他们都听之任之。如果我切换DGCBC回DGTC的正确结合显示为不是真或假。任何想法?

After I set the source for the DataGrid the checkbox column shows up, but they are all unchecked. If I switch the DGCBC back to a DGTC the binding correctly shows up as either "true" or "false". Any ideas?

谢谢,

桑尼

Thanks,
Sonny

推荐答案

请问您需要的结合将模式=双向?

Does your binding need to be Mode=TwoWay?

这篇关于WPF - 编程方式绑定到DataGridCheckBoxColumn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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