Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
170
XamCheckboxEditor ValueChanged to uncheck the box?
posted

I have a checkbox, that when you check it, it brings up a messagebox trying to verify that you are sure you want to check the box.  The problem is, if you set the value back to false, using INotifyChanged, it still makes the checkbox checked.  Is there any other way to do this, or am I missing something?

I attached a sample project showing exactly what is going on.

Thanks

CheckBoxValueChangedExample.rar
Parents
  • 54937
    Offline posted

    This is actually a bug/behavior in WPF. It looks like while WPF is updating the source binding it doesn't take the value from the source after it sets it and instead continues to use the value it was being changed to. So in this case the CheckBox is updating its IsChecked to true. That pushes true into the XamCheckEditor's IsChecked which results in the ValueChanged being invoked. You are changing the value of the source (but it happens even if you set the XCE's IsChecked), and that pushes into the XamCheckEditor's IsChecked but the CheckBox which was in the process of pushing the property change to true into the source continues on to change its IsChecked property to true. I would recommend not changing it directly in this event but instead doing a BeginInvoke on the Dispatcher and set it back there. Note, I tested this out with WPF 4 and it works properly so it seems like MS addressed this in that version.

Reply Children
No Data