1
Answer

Bind Multiple Checkboxes to Specific cells of a Datatable

Shane Hickey

Shane Hickey

10y
776
1
 

Hi all,

          I have an application that has many Checkboxes (> 100). I also have a datatable that has 2 columns (1 of type string and 1 of type bool). Is there any simply way that I enable two way binding between each Checkbox and the datatable?

Specifically what I'm trying to do is for a checkbox, I'm try to use IsChecked="{Binding Path= XXX, Mode=TwoWay}" where XXX represents the cell of the datatable. How I identify the cell is by the fact that

1) The column is always column 1, i.e. the Boolean column

2) The row is determined by the Name of the checkbox using the binding. For every checkbox, I have an entry in column 0 of the datatable with that Checkbox's name. Therefore the idea is that based on the Checkbox name I should be able to identify the row of the datatable and update the bool column of that row with the state of the checkbox, true or false.

 

My biggest problem is that this binding needs to be two way so any updates to my datatable within my code would also update the tick status of a checkbox. If I only needed oneway, I could do this easily enough by defining methods for Checked and Unchecked and using the sender Name within those methods to identify the row of the datatable.

All feedback appreciated. Please keep it simple cause I ain't no expert!

Cheers

Shav


Answers (1)
Next Recommended Forum