如何设置从Xceed \Extended WPF Toolkit的datagrid控件与复选框列和绑定 [英] How to set up the datagrid control from the Xceed\Extended WPF Toolkit with checkbox column and binding

查看:706
本文介绍了如何设置从Xceed \Extended WPF Toolkit的datagrid控件与复选框列和绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将一个WPF数据网格交换到一个xceed \Extended WPF Toolkit DataGridControl。



我需要对复选框列中的点击事件做出反应



在现有的datagrid中,我有一个checkbox列,它绑定到一个Observable集合,我调用一个方法如果任何复选框被选中\unchecked。我使用的这个xaml是这样的:

 < DataGridTemplateColumn Width =40Header =Inc > 
< DataGridTemplateColumn.CellTemplate>
< DataTemplate>
< CheckBox
IsChecked ={Binding Include,Mode = TwoWay,UpdateSourceTrigger = PropertyChanged}
Checked =CheckBoxUpdatedUnchecked =CheckBoxUpdated/&
< / DataTemplate>
< /DataGridTemplateColumn.CellTemplate>





对于xceed datagrid控件,与下面的简单语法,并且初始绑定似乎确定,但我没有点击事件响应:

 < xcdg:Column FieldName =IncludeTitle =Inc/> 

现在我试图使用xceed datagridcontrol做类似于原始代码的操作, p>

 < xcdg:Column FieldName =IncludeTitle =IncWidth =*> 
< xcdg:Column.CellContentTemplate>
< DataTemplate>
< CheckBox IsChecked ={Binding Include,UpdateSourceTrigger = PropertyChanged,Mode = TwoWay}Click =CheckBoxUpdated/>
< / DataTemplate>
< / xcdg:Column.CellContentTemplate>



这是正确的语法。看起来绑定不工作...基于集合的初始值。



(注意代码背后设置此项目源如此dg.ItemsSource = collectionView; )



有关如何正确设置复选框DataTemplate和绑定的任何想法?




解决方案

我刚刚在 xceed论坛,给我我需要的语法,设置FieldName =。,而不是FieldName =包括。我的猜测是有FieldName =包括和{绑定包括...混淆的绑定。

  ; xcdg:ColumnName =。 Title =IncWidth =*> 
< xcdg:Column.CellContentTemplate>
< DataTemplate>
< CheckBox IsChecked ={Binding Include,UpdateSourceTrigger = PropertyChanged,Mode = TwoWay}Click =CheckBoxUpdated/>
< / DataTemplate>
< / xcdg:Column.CellContentTemplate>


I'm trying to swap out a WPF datagrid to a xceed\Extended WPF Toolkit DataGridControl.

I need to react to the click event in a checkbox column ... to summarizing a number of other columns.

In the existing datagrid I have a checkbox column, that is bound to a Observable Collection and I call a method if any check box is checked\unchecked. The xaml I use for this, which works, is as such:

<DataGridTemplateColumn Width="40" Header="Inc">
<DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
        <CheckBox
            IsChecked="{Binding Include ,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
            Checked="CheckBoxUpdated" Unchecked="CheckBoxUpdated" />
    </DataTemplate>
</DataGridTemplateColumn.CellTemplate>

For the xceed datagridcontrol I started with the simple syntax below, and the the initial binding seemed OK, but I don't have a click event to respond to:

<xcdg:Column   FieldName="Include" Title="Inc" />

Now I tried to do something similar to the original code using the xceed datagridcontrol, as such:

<xcdg:Column   FieldName="Include" Title="Inc" Width="*" >
<xcdg:Column.CellContentTemplate>
    <DataTemplate>
        <CheckBox IsChecked="{Binding Include ,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Click="CheckBoxUpdated"/>
    </DataTemplate>
</xcdg:Column.CellContentTemplate>

But I don't think this is the correct syntax. It seems the binding is not working ... based on the initial values of the collection.

(note code behind sets this items source as such dg.ItemsSource = collectionView;)

Any ideas on how to setup a checkbox DataTemplate and the binding correctly?

Thanks

解决方案

I just found a post at xceed forums that gave me the syntax I needed, that to set the FieldName=".", not FieldName="Include" . My guess is that having FieldName="Include" and the "{Binding Include ..." was confusing the binding.

<xcdg:Column   FieldName="." Title="Inc" Width="*" >
 <xcdg:Column.CellContentTemplate>
  <DataTemplate>
    <CheckBox IsChecked="{Binding Include ,UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Click="CheckBoxUpdated"/>
</DataTemplate>
</xcdg:Column.CellContentTemplate>

这篇关于如何设置从Xceed \Extended WPF Toolkit的datagrid控件与复选框列和绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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