ListBox选定索引颜色wpf

发布于 2024-08-19 07:56:11 字数 227 浏览 3 评论 0原文

我刚刚开始使用 WPF,我有这个显示属性的 ListBox 来自我做的一堂课。当我执行以下操作时,我必须以编程方式更改选定的索引:

ListBox1.SelectedIndex = 4; 

SelectedIndex 已更改并突出显示为灰色,但如果我单击它,则选定的索引为蓝色。我还需要做些什么才能让两者表现相同吗?

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 SelectedIndex 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一生独一 2024-08-26 07:56:11

听起来焦点不在 ListBox 上。更改 SelectedIndex 后尝试 ListBox1.Focus()

Sounds like the focus is not on the ListBox. Try ListBox1.Focus() after changing the SelectedIndex.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文