I am just starting with WPF and I have this ListBox that displays an attribute from a class I made. I have to programmatically change the selected index, when I do something like: ListBox1.SelectedIndex = 4; the selected index is changed and highlighted gray, but if I click on it, the selected index is blue. Is there something else i need to do to have both behave the same?
+2
A:
Sounds like the focus is not on the ListBox. Try ListBox1.Focus()
after changing the SelectedIndex.
Heinzi
2010-01-28 16:01:34
huh...yeah that works, I imagine that's consistent behavior across all the controls. Changing attributes programmatically doesn't give them the focus. Thank you
irco
2010-01-28 16:19:23