DataGridCheckBoxColumn binding problem

May 12, 2009 at 5:54 PM

I've got a DataGridCheckBoxColumn  that's bound to a boolean property on an object. When I check the checkbox, on the grid it gets checked, and it sets the property on the object to true. When I save the object to the database, it saves it as true, so that works great. But, when I reload the page (say after doing a search), the checkbox is NOT checked, even though the underlying object's property is set to true.

Any ideas?


May 12, 2009 at 9:32 PM

Hey Chris, What are you doing to "reload the page"?

May 12, 2009 at 9:38 PM

Hi Alexis,

When I say 'reload' the page, I mean if a user leaves the application, then opens it back up, or searches on something. I do a query from the database populating the objects, then the objects are bound to the datagrid when I set the datacontext of the grid to the business object list (an observableCollection).

The rest of the properties display properly in the grid, but not the checkbox column, even though when I examine the business object coming back, it's set to True, but the checkbox column is not being checked.




May 12, 2009 at 9:59 PM

Weird.  Does it reflects the value accurately the first time you start the app (whether it is true or false)?  If you attach your project we will take a look.

May 12, 2009 at 10:14 PM
Edited May 12, 2009 at 10:53 PM

Hi Alexis,

It does reflect the value accurately when I add a row, set the the value by checking the checkbox. Once I save it, it looks like the grid / screen refresh, and it's no longer there. Is it something to do with the IsChecked vs. bool - do I need a converter on there?

I can't attach the entire project, but I can post some source code. Here's the XAML for that checkbox column, the  FloodZone property is a bool.

<wpftk:DataGridCheckBoxColumn  Binding="{Binding Path=FloodZone}"   CellStyle="{StaticResource SingleClickEditing}" />

May 13, 2009 at 3:41 PM

Hi Alexis,

Do you see anything in that XAML that might stick out as to why it's not working?

May 13, 2009 at 5:54 PM

Hi Alexis, I figured it out, the problem was in the underlying BO code. Thanks for your help though!