✅ ComboBox selected item can only be updated from binding property, not the control itself
I'm attempting to use a combo box with a collection of records the user can select from. I can get the items to render in the control, and can set a default value, but the combo box will not update when you select one of the values from the dropdown. I set breakpoints on anything I could think of from the bound property, various
XxxChanged events, etc.
All I could find online were specific errors, which were solved by reordering the properties, which didn't apply to me because my formatter had done that already.
This is the relevant code:
ui being WpfUi: https://wpfui.lepo.co/
The attached image shows what the combo box looks like. The selection doesn't update after clicking an item.
27 Replies
does the output show you anything meaningful during runtime?
eg property not found or something
nope, i get zero errors
everything seems to be bound correctly, it seems like the combo box just isnt setting the value
sorry for responding to you directly, but i just found that it only works when you use your mouse wheel on the control to cycle through the items
so you cannot manually pick which item you want, but scrolling will update it
id still like to figure out how to use the combo box properly for user experience, though lol
do u have a minimal repro on github?
Also why are u using both
its highly like they are affecting eachother depending what ur doing
i added the event to test it with breakpoints, the event handler is empty and has been removed since the post was made
i updated the post to remove the unused event handler
u can breakpoint on the source generator for the SelectedJavaVersion
anyway if u post a minimal repro on github I will clone and check out
i copied my code over into a new project, but the combo box is working (shocker)
im trying to find differences because combo boxes work the same way in all pages, so i assumed its something in the window
i just cannot find anything that replicated my issue in the new project
try adding more of what is around it then
i added a mousedown event handler in my original app, and its gets triggered by the combo box
its just the item is not updated
sorry that didnt make much sense
it works when i put it into my window xaml, but not when i put it in a page
sorry, im writing as i find things
UI/client events are raised but they are either: not propagated/read by the parent combobox or the combobox doesn't update the value for an unknown reason
u shouldnt need UpdateSourceTrigger=PropertyChanged
either
i just did it to be sure
it fixed some other issues i had in the past
this is what it currently looks like:
can you try with the default textblock instead
could be something to do with hitbox
if u reach a point u can repro the issue that would be best as I would be able to actually see what is going on and perhaps explain and provide a way to do it
the events shouldn't be raised then no?
i did, unfortunately didnt fix the issue
as for the breakpoint you will usually see something like this with source generator

it only happens when placed in one of my pages, even if its the first element, and it doesnt matter which page
correct
so if u need to breakpoint u can go in there and bp
i usually just make a partial method for onchanged so i can still see the viewmodel :p
yeah partial props are new thingy
is the project open?
both are, yes
is there a github link of the specific commit your working on
no, i havent pushed changes in a super long time
:catsweat:
hey, i fixed it
it was an event handler for mouse clicks on the window i was using to help with unfocusing textboxes/buttons when clicking off of them
i swear i tested it, but i think my "test" was to use hot reload, which likely did nothing...
!solved
what was the command
.solved
-# got it