i binding dictionary combobox itemsource. binds properly, when run program, click on drop down, click on item...nothing happens.
other useful information, when click text of each item, can see faint box/border around text. if click inside box, nothing happens. if click outside box, things work expected. thoughts?
my xaml code:
<combobox name="payloaddrop"> <combobox.itemtemplate> <itemcontainertemplate> <comboboxitem tag="{binding path=key}" content="{binding path=value}" /> </itemcontainertemplate> </combobox.itemtemplate> </combobox> and code behind:
dim payloaddictionary new dictionary(of int16, string) _ {{0, "some payload text"}, {1, "path payload file"}} payloaddrop.itemssource = payloaddictionary below screenshot of combo box looks like...

i've never had experience itemcontainertemplate, far understand, case same datatemplate. (there no mention of resources or menubase or statusbar)
you have collection of keyvaluepair items itemssource. keyvaluepair not comboboxitem, combobox decides create container - comboboxitem. container needs way display item data, , have set itemtemplate that, result another comboboxitem created inside container. so, have comboboxitem inside comboboxitem. external comboboxitem connected combobox, combobox recieves clicks. internal comboboxitem displayed faint border , disconnected, there no reaction click events.
there 2 possible ways change xaml: either use correct datatemplate itemtemplate, or style itemcontainerstyle. understand, task display value preserve information key (id of kind) well, should use correct datatemplate:
<combobox x:name="payloaddrop"> <combobox.itemtemplate> <datatemplate> <textblock text="{binding value, mode=onetime}"/> </datatemplate> </combobox.itemtemplate> </combobox> in case combobox display value. can access selectedvalue property. selecteditem property contain underlying keyvaluepair. since keyvaluepair not implement inotifypropertychanged, essential use mode=onetime evade memory leaks.
Comments
Post a Comment