开发者

Set focus in Listbox in MVVM pattern

开发者 https://www.devze.com 2023-04-03 23:09 出处:网络
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 fi

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号