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 SelectedI开发者_开发知识库ndex 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?
Sounds like the focus is not on the ListBox. Try ListBox1.Focus() after changing the SelectedIndex.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论