WPF how to force menu item bindings to update when menu opens -


i have value can change doesn't raise change event , menu item bound value doesn't correctly reflect state when menu item opened. i'd update binding when menu opens. how do this?

can have menu item polls it's bindings each time menu opened? in case iscommenabled property:

<menuitem header="{binding enablecomm}"       command="{binding root.togglecommunications}"     ischecked="{binding authorization.iscommenabled, mode=oneway,         updatesourcetrigger=propertychanged}"/> 

--

    public bool iscommenabled {         { return _communications.iscommenabled; }     } 

you can subscribe submenuopened event, , manually update binding:

void menuitem_submenuopened(object sender, routedeventargs e) {     ((menuitem)sender).getbindingexpression(menuitem.ischeckedproperty).updatetarget(); } 

please note above applies parent item being opened, may need wrangle bit ensure right item getting updated. can use items collection on menuitem dig deeper.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -