开发者

DataGridCheckBoxColumn updates source and is validated only after focus loss

开发者 https://www.devze.com 2023-01-12 15:18 出处:网络
I have a problem with DataGrid from WPFToolkit. My grid has DataGridCheckBoxColumn. When I change value of some cell in this column, validation and real source updating occures only after a cell has l

I have a problem with DataGrid from WPFToolkit. My grid has DataGridCheckBoxColumn. When I change value of some cell in this column, validation and real source updating occures only after a cell has lost focus. So, if I change checkbox value in a cell and leave focus inside it, the property of a binded object wouldn't be changed.

Column's binding property UpdateSourceTrig开发者_StackOverflow中文版ger is set to PropertyChanged and Mode is set to TwoWay.

How can I make binding update my source object immediatly after a checkbox value has been changed?


I don't know for the toolkit-version but with the .net4 version, the binding works as expected. Check your binding-declaration:

<DataGridCheckBoxColumn Binding="{Binding YourProperty,UpdateSourceTrigger=PropertyChanged}">

If it's a specific problem of the toolkit-version, create a DataGridTemplateColumn and place a CheckBox in the cell-or edit-template and declare the binding on the CheckBox-control. This will help.

<dg:DataGridTemplateColumn > 
       <dg:DataGridTemplateColumn.CellTemplate> 
             <DataTemplate> 
                    <CheckBox IsChecked="{Binding YourProperty,UpdateSourceTrigger=PropertyChanged}" /> 
             </DataTemplate> 
       </dg:DataGridTemplateColumn.CellTemplate> 
</dg:DataGridTemplateColumn> 
0

精彩评论

暂无评论...
验证码 换一张
取 消