wpf - Datagrid Custom Combobox not Updating -


i'm having issue wpf datagrid's datagridtemplatecolumn , updating items display on combobox based off of user's interaction. since program database bound, doesn't make sense load items database @ once, instead uses entity framework pull user requests @ given moment.

to facilitate view that's compact, next/previous buttons on combobox template, search functionality, issue i'm running is: when templated comboboxes in datagrid, next/previous not function. outside of datagrid function properly.

i've tried using knowledge combobox present , manually pulled visual tree doing search combobox name, pulled binding itemssource , told update. nothing happens.

here image of mean below: enter image description here

the display update once select new cell; however, since capture when it's enter edit mode , update list contain item selected (for binding purposes, comboboxes don't have selected item that's not in item set.)

as can imagine, rather big issue. it's difficult continue developing until resolution found. known issue datagrids? if so, might have roll own. don't want performance reasons, i'm no mvvm expert, reason ui looks it's defining itself, within itself.

i'm daft, that's problem:

private static void updatecombodropdown(string comboboxname, datagrid datagrid) {     /* *      * think currentitem used in instance because       * it's single cell selection mode?      * *      * cba check.      * */     var selectedrow = datagrid.itemcontainergenerator.containerfromitem(datagrid.currentitem) datagridrow;     if (selectedrow != null)     {         datagridcellspresenter presenter = getvisualchild<datagridcellspresenter>(selectedrow);         if (presenter != null)         {              var visualcombobox = presenter.findchild<combobox>(comboboxname);             if (visualcombobox != null)             {                 var binding = visualcombobox.getbindingexpression(combobox.itemssourceproperty);                 if (binding != null)                     binding.updatetarget();             }             var popuppart = visualcombobox.findchild<popup>("part_popup");             if (popuppart != null && popuppart.child != null)             {                 //popup has 1 child, reports 0 children, so: search on child.                 var previous = popuppart.child.findchild<button>("previousbutton");                 if (previous != null)                 {                     var previousisenabledbinding = previous.getbindingexpression(button.isenabledproperty);                     if (previousisenabledbinding != null)                         previousisenabledbinding.updatetarget();                 }                 var next = popuppart.child.findchild<button>("nextbutton");                 if (next != null)                 {                     var nextisenabledbinding = next.getbindingexpression(button.isenabledproperty);                     if (nextisenabledbinding != null)                         nextisenabledbinding.updatetarget();                 }             }         };     } } 

i telling update itemssource of combobox, not other way around. why relationship isn't automatically updating, don't know. find out how update constituent elements of combobox controls in dropdown. involve getting part_popup, next/previous buttons , respective bindings. annoying.

edit: updated answer full solution.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -