How to prevent WPF Checkbox inside a Button from being checked by double-click? -


i have wpf button content has bunch of controls including checkbox.

currently single-click on checkbox fires "checked" event, that's fine.

what don't double-click fires "checked" event.

currently double-click triggers both checkbox' "checked" event , button's "doubleclicked" event.

what want double-click on checkbox should trigger button's event, not checkbox's event. checkbox should checked upon single-click.

is there way that?

thanks.

what trying might not make best user experience because you're going have implement delay prior processing user's attempt check box.

why?

well, if double click checkbox, want nothing happen checkbox, want pass control button. that's totally understandable.

but happens if click checkbox? @ moment release mouse button, going expect check mark appear. system can't yet know don't plan click again. so, has wait through doubleclicktime determine in fact never double-clicked.

you have weigh worse: delay when checking checkbox vs. flicker when double-clicking checkbox.

if decide go delay, you'll need implement yourself. here's basic procedure should work:

  1. create handler checkbox.previewmousedown. within handler, disable checkbox , start dispatchertimer interval of doubleclicktime.
  2. meanwhile, create handler button.mousedoubleclick sets field, _hasdoubleclicked, true.
  3. when timer goes off, enable checkbox, , if _hasdoubleclicked false, toggle ischecked of checkbox. also, set _hasdoubleclick = false.

as can see not pretty. might want ask if there way achieve goal different design. need use double-click in first place?


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -