list box selected index won't update
I have a strange problem that came out of no where... 开发者_运维知识库 When I attempt to update a list box selected index in code it will only update if I do the following lstbox.selectedindex = 4 or any other number in the range.
If I do lstbox.selectedindex++ or lstbox.selectedindex += 1 or lstbox.selectedindex = var; It will not update the index the selected index will not update.
I am using C# and wpf
Any help would be great!
Interesting. I tested this and it would appear that the SelectedIndex property updates, but the controls appearance does not update until it has gained focus for the first time (calling InvalidateVisual() and UpdateLayout() does not update the control UI, but calling Focus() or selecting an item before setting the SelectedIndex will).
Edit: Ignore that, it is updating the selected item but the contrast between the window background and the unfocused highlight was so slight on my screen that I didn't notice it, what a fool I feel :p
I fixed it by adding the handler on page load and not in XMAL. Strange issue still don't fully understand it or how it happend
精彩评论