I think I have found a bug. If I populate a list of MenuItems in a button’s collection of menu items programatically, each menu item when clicked will raise the button’s ItemClicked event appropriately.
However – if I then clear the list of menuitems, and re-populate it again programatically, the event will no longer fire.
I am trying to build some selectors using drop down buttons, and button B’s contents will depend on button A’s selection – so I have to dynamically repopulate the list of menu items under button B. And it doesn’t work because the ItemClicked event no longer fires.
The same problem holds true for SplitButton too.
Is this a bug or am I doing something wrong? If a bug is there any work around? The only work around I can find is to use a combo box instead of a button, which works, but doesn’t give the appearance we want.
Attached is a small sample that clearly shows the problem. Click one of the “Use” buttons and the event will fire. Click another “Use…” button to repopulate the drop down button’s items – and the event no longer fires.
Thanks in advance for your help!
Yes, logged as WJ-9126: Menu items added to a Button or SplitButton after creation don’t fire the ItemClick event.
It’s fixed in our build will make it to this upcoming dev build. Should be by Monday. You can work around it, in case you need it quicker, by attaching to the Click event of the menu items.
Please login first to submit.