Set focus in Listbox in MVVM pattern
I am trying to set a focus on the first Item of listBox. I am binding the value to listbox, contaning a textbox by a onpropertyc开发者_StackOverflow中文版hange method and I want to set focus in the first item. how can I achieve that?
you can set focus on the first item with the following:
listBox1.Items[0].Focused = true;
you may also want to have the item that is focused to be selected, if you do then:
listBox1.Items[0].Selected = true;
Just remember the [0] above means the first index. [1] would be the second and so on.
精彩评论