Search code examples
c#wpfxamldata-bindingwpfdatagrid

WPF datagrid control binding enables, but takes 2 clicks on the control


Sorry about the pretty meticulous question but I am pretty stuck.

I have a datagrid, inside the datagrid are two column controls a checkbox, and a datetime picker. I have binded the datetime picker to only be enabled when the checkbox is checked. It's working.. except the datetime picker is not activated right away, I have to click inside the date time picker column twice for it to enable. Immediately after checking off the checkbox i make sure the checkbox checked value is correct, and it is. I am trying to just polish my form and this is annoying me. Any help is appreciated!

My XAML Code:

            <DataGridTemplateColumn Header="MyCheckBox" Width="60">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <CheckBox  IsChecked="{Binding checkboxChecked, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"></CheckBox>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn Header="Reminder Date" Width="100">
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <xctk:DateTimePicker Format="Custom" FormatString="M/d/yyyy h:mm" IsEnabled="{Binding Path=checkboxChecked, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                                             Value="{Binding checkboxDate, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"/>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>

Additional info: I also tested this button on other controls like a text box, it also takes 2 clicks inside the text box to enable it. Also the date time picker is part of the extended WPF toolkit but that doesn't seem to matter since it happens for other controls.

EDIT: ISSUE RESOLVED... It's really late at night ... I forgot to add a call for the checkboxChecked property to PropertyChanged in my object that implements INotifyPropertyChanged.


Solution

  • I forgot to add a call for the checkboxChecked property to PropertyChanged in my object that implements INotifyPropertyChanged.